This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
New revision of select() hangs my code
- From: Dan Jakubiec <dan at systech dot com>
- To: "'ecos-discuss at sources dot redhat dot com'" <ecos-discuss at sources dot redhat dot com>, "'nickg at ecoscentric dot com'" <nickg at ecoscentric dot com>
- Date: Fri, 22 Nov 2002 14:41:09 -0800
- Subject: [ECOS] New revision of select() hangs my code
> I just grabbed the latest version of
> ecos/packages/io/fileio/current/src/select.cxx (I went from rev 1.8 to
> 1.9). The changes in this file break my current code which uses the
> select() call. I looked through the code changes, but didn't see anything
> obviously wrong.
>
> Nick Garnett: Would you mind having a look at this to see if you can see
> something?
>
> My code just issues a select() call with a timeout of 0 to poll the read
> state of a TCP socket. Here is the gist of what my code does:
>
> void my_func()
> {
> fd_set read_fds;
> struct timeval timeout;
> int s; /* TCP socket */
> int net_ok;
> char buf[128];
>
> /* The "s" file descriptor is a connected TCP socket */
> ...
>
> FD_ZERO(&read_fds);
> FD_SET(s, &read_fds);
> timeout.tv_sec = timeout.tv_usec = 0;
> net_ok = TRUE;
> while (net_ok &&
> (select(s+1, &read_fds, NULL, NULL, &timeout) > 0) &&
> FD_ISSET(s, &read_fds))
> {
> diag_printf("got data\n");
> net_ok = (read(s, buf, sizeof(buf)) > 0);
>
> }
> diag_printf("Finished flushing data\n");
>
> }
>
>
> With revision 1.8 of select.cxx, the code works fine (ie. it returns
> immediately with the socket state). With revision 1.9 of select.cxx, the
> select() call hangs on the first call and does not return (ie. neither of
> my diag_printf()'s come out). Any ideas?
>
> --
> Dan Jakubiec
> Systech Corporation
> dan@systech.com
>
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss