Re: 2.2 generating odd TCP resets?

From: dean gaudet (dean-list-linux-kernel@arctic.org)
Date: Thu Oct 19 2000 - 14:42:58 EST


On Wed, 18 Oct 2000, Brian Craft wrote:

> In the code below, I removed the shutdown() and added the block
> after do_scan() to eliminate the RST. The read() never finds any data.
> If there's no data pending, why does read() have any affect?

EOF is considered pending data... and has to be read.

this first snippet you posted would clear the EOF:

> b.c.
>
>
> fcntl (data_fd, F_SETFL, 1); /* set non-blocking */
> /* shutdown (data_fd, 0); */
> do_scan (w, h, data_fd);
> {
> char buff[10];
> int i, c;
> printf("looking for extra data\n");
> while ((c = read(data_fd, buff, 10)) >= 0) {
> if (c > 0) {
> for (i=0; i<c; ++i) {
> printf("%x ", buff[i]);
> }
> printf("\n");
> }
> }
> printf("no more data\n");
> }
> close (data_fd);

but in this next message with the "st" program, the read() doesn't clear
the EOF...

On Wed, 18 Oct 2000, Brian Craft wrote:

> while (count < LEN) {
> n = read(fd, buff, 100);
> if (n < 0) {
> printf("error on read\n");
> break;
> }
> count += n;
> }

you need one more read() to clear the EOF.

i'm not saying this totally explains the problems you're seeing, but i
think it's suspect.

-dean

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:15 EST