bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] Issue with read timeout on TCP socket


From: Serge A. Zaitsev
Subject: [bug-gawk] Issue with read timeout on TCP socket
Date: Thu, 30 May 2013 02:21:29 +0300

Hi, guys!

I'm using Gawk 4.1.0, and it seems like it's working not as expected with TCP sockets.
Here's my sample script:

BEGIN {
server = "/inet4/tcp/0/127.0.0.1/12345"
PROCINFO[server, "READ_TIMEOUT"] = 1000
for (i = 0; i < 10; i++) {
if ((server |& getline) > 0) {
print(">>", $0);
} else {
print(ERRNO);
}
}
}

It should be simple - I connect to localhost:12345, then read with timeout for 10 times.
What I expect to see is: 10 times a 1sec timeout if no data available, with corresponding ERRNO.
What I see is: once a 1sec timeout, then immediate loop iterations with no timeout.

I did some debugging, and seems like get_a_record() in io.c has the following check:

if (at_eof(iop) && no_data_left(iop))
return EOF;

Which is always true after the timeout, because IOP_AT_EOF flag is always set if select() returns -1 (which is select() error, e.g. timeout).
For my case I removed the line io.c:3351 (I'm talking about 4.1.0 sources form the tarball) and that helped.
I'm sure this will break other things in Awk, so could you please look for a proper solution?

Actually, maybe I just to it wrong? Are there any other ways to "poll" periodically for TCP sockets in a loop?

Regards,
Serge


--
"One must have a chaos inside oneself to give birth to a dancing star." - Thus Spoke Zarathustra

reply via email to

[Prev in Thread] Current Thread [Next in Thread]