lkml.org 
[lkml]   [2005]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectPossible problem in fcntl
Hi,

We have written a little webserver for our CS course. But we have a
problem with fcntl.
We are using non-blocking sockets and per fcntl man page:
On Linux, the new socket returned by accept () does not inherit file
status flags such as O_NONBLOCK and O_ASYNC from the listening socket.
This behaviour differs from the canonical BSD sockets implementation.
Portable programs should not rely on inheritance or non-inheritance of
file status flags and always explicitly set all required flags on the
socket returned from accept().

We call fcntl after calling bind and listen. Then we also call fcntl
for each accept'ed connection to set O_NONBLOCK:
flags = fcntl(e, F_GETFL);
fcntl(e, F_SETFL, flags | O_NONBLOCK);

$ uname -a
Linux lab9p2 2.6.11.12 #3 Sat Sep 3 20:09:17 WEST 2005 i686 Intel(R)
Pentium(R) 4 CPU 2.26GHz GenuineIntel GNU/Linux
$

The code is at http://mega.ist.utl.pt/~facab/proj/
(files httpd.n.[ch] have the line numbers)
The line that's causing the trouble is line 377 in httpd.c. Commenting
that line fixes the problem (although we think that shouldn't be
necessary).

However, in my laptop (with a different kernel version) it works. So,
does this kernel version (2.6.11.12) has a bug with fcntl or are we
doing something wrong?


Thanks in advance,
Filipe Cabecinhas

P.S: Please CC me, because I'm not subscribed to this list.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-12-13 16:59    [W:0.115 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site