All of lore.kernel.org
 help / color / mirror / Atom feed
From: "linux-os \(Dick Johnson\)" <linux-os@analogic.com>
To: "Filipe Cabecinhas" <filcab@gmail.com>
Cc: linux-kernel@vger.kernel.org, "Nuno Lopes" <ncpl@mega.ist.utl.pt>,
	"Renato Crisóstomo" <racc@mega.ist.utl.pt>
Subject: Re: Possible problem in fcntl
Date: Tue, 13 Dec 2005 12:50:04 -0500	[thread overview]
Message-ID: <Pine.LNX.4.61.0512131242280.8370@chaos.analogic.com> (raw)
In-Reply-To: <e46c534c0512130756k18c409aen3d60df7aaee50062@mail.gmail.com>


On Tue, 13 Dec 2005, Filipe Cabecinhas wrote:

> 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().
>

Okay already. What is it that it doesn't do that you expect it to do?

> 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).
>

So what is it that the socket doesn't do, that you expect it
should do?

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

What is it that you expect it to do? Networking exists at several
levels. You may have to use setsockopt() to set some socket parameters
for some kinds of sockets. The 'fact' that something worked in
some previous code does not mean that the code was correct.

> Thanks in advance,
> Filipe Cabecinhas
>
> P.S: Please CC me, because I'm not subscribed to this list.
> -

Cheers,
Dick Johnson
Penguin : Linux version 2.6.13.4 on an i686 machine (5589.56 BogoMips).
Warning : 98.36% of all statistics are fiction.
.

****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

  reply	other threads:[~2005-12-13 17:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-13 15:56 Possible problem in fcntl Filipe Cabecinhas
2005-12-13 17:50 ` linux-os (Dick Johnson) [this message]
2005-12-13 18:30   ` Filipe Cabecinhas
2005-12-13 18:46     ` linux-os (Dick Johnson)
2005-12-13 20:42       ` Filipe Cabecinhas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0512131242280.8370@chaos.analogic.com \
    --to=linux-os@analogic.com \
    --cc=filcab@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ncpl@mega.ist.utl.pt \
    --cc=racc@mega.ist.utl.pt \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.