9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: lucio@proxima.alt.za
To: 9fans@9fans.net
Subject: Re: [9fans] APE and listen(2B)
Date: Thu, 27 Nov 2008 11:40:30 +0200	[thread overview]
Message-ID: <958730dc6591e0e7f22563817436238e@proxima.alt.za> (raw)
In-Reply-To: <140e7ec30811262349m764d4166kdd44141bf6afc2a3@mail.gmail.com>

>  After removing the (socklen_t*) typecast...
> # pcc -o reveal -D_POSIX_SOURCE -D_BSD_EXTENSION reveal.c -lbsd
> # ./reveal
> ERRNO: 12
> socket accept: Invalid argument

The precise error I get as well.  Thank you for confirming.  I'd
forgotten that one of the reasons for doing this was to add
"socklen_t" to the typedefs.

Let me add a bit of diagnostic information.

The ERRNO 12 is way out, ENOMEM has nothing to do with this.

The error seems to stem from two connected problems: the actual site
of the error lies with an attempt to open("/net/tcp/27/listen",
O_RDWR) when the specific connection has not been announce()d (in Plan
9 terms).  The reason for the error is that the code in
/sys/src/ape/listen.c:/^listenproc guarded by the for(;;) gets as far
as the cfd = open(listen, O_RDWR); but never returns from there, it
seems literally to exit() at this point.  Once the code exits, I
presume it closes the descriptor which causes the later "open" to
fail.

We know that the parent code closes the actual "socket" (nfd =
dup(fd); ...  close(nfd);) as well as the unused end of the pipe
(close (pfd[1]);) and then returns to the caller and thence to the
caller of the listen() procedure.

The child process, which ought to supply the name of the network
control file (/net/tcp/27/ctl in this case) never gets to the stage
where it can put this information in the "listen" file because it
can't even open it successfully.

There's clearly an error here and the worst symptom I can identify is
that the "/net/tcp/27/listen" file cannot be opened and that the
failure is both silent and fatal.  Here I'm afraid I'm right out of my
depths.

++L

PS: all disclaimers apply, there are too many nooks and crannies here
for me to feel confident that what I'm seeing is in fact what is
happening.




  reply	other threads:[~2008-11-27  9:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-27  4:35 lucio
2008-11-27  7:49 ` sqweek
2008-11-27  9:40   ` lucio [this message]
2008-11-27 14:54   ` erik quanstrom
2008-11-27 15:16     ` lucio
2008-11-28 17:24 ` Skip Tavakkolian
2008-12-04 17:18 lucio

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=958730dc6591e0e7f22563817436238e@proxima.alt.za \
    --to=lucio@proxima.alt.za \
    --cc=9fans@9fans.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).