bug-gawk
[Top][All Lists]
Advanced

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

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


From: Aharon Robbins
Subject: Re: [bug-gawk] Issue with read timeout on TCP socket
Date: Thu, 27 Jun 2013 17:01:36 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Hi. Sorry for the long delay in replying to this.

> Date: Thu, 30 May 2013 02:21:29 +0300
> From: "Serge A. Zaitsev" <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] Issue with read timeout on TCP socket
>
> 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 don't have anything listening on that port so I get quick failures.

> 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?

What if you add

        close(server)

in the case where it fails?

Arnold



reply via email to

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