From: andrey mirtchovski <mirtchov@cpsc.ucalgary.ca>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] accept in dial(2)
Date: Tue, 17 Aug 2004 09:36:11 -0600 [thread overview]
Message-ID: <766d57de8595663bf37db32ddf91abc7@plan9.ucalgary.ca> (raw)
In-Reply-To: <fa2bd26e06e99ec4303411b3e28ec90b@collyer.net>
> There seems to be some confusion about which file descriptor
> accept should take as its first argument: the one announce
> returned, the one listen returned, or it doesn't matter.
> A quick kernel grep suggests that only port/devsdp.c still
> recognises the word "accept", per the comment
>
> write(ctl, buf, n); /* ignore return value, network might not need accepts */
>
> at /sys/src/libc/9sys/announce.c:148. dial(2) says
> ``Accept accepts a call received by listen'', which
> isn't completely clear, but the example given uses
> the fd returned by listen, which makes sense to me.
> On the other hand, listen, listen1 and tftpd use the
> fd returned by announce.
>
> Does anybody know which fd accept should take, and if it
> matters?
the listen one, i believe.
here's a snippet from a service not unlike any other fs in p9:
acfd = announce("tcp!*!18000", adir);
if(acfd < 0)
sysfatal("announce: %r");
for(;;){
lcfd = listen(adir, ldir);
if(lcfd < 0)
sysfatal("listen: %r");
switch(rfork(RFPROC | RFMEM | RFNOWAIT)){
case -1:
fprint(2, "fork listen: %r");
continue;
default:
continue;
case 0:
break;
}
dfd = accept(lcfd, ldir);
if(dfd < 0)
sysfatal("accept: %r");
s = emalloc9p(sizeof *s);
*s = fs;
s->infd = s->outfd = dfd;
srv(s);
free(s);
_exits(nil);
}
andrey
next prev parent reply other threads:[~2004-08-17 15:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-17 3:30 geoff
2004-08-17 15:36 ` andrey mirtchovski [this message]
2004-08-17 16:03 ` rog
2004-08-17 17:51 ` rog
2004-08-17 21:12 ` Russ Cox
2004-08-18 17:33 ` rog
2004-08-18 19:18 ` boyd, rounin
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=766d57de8595663bf37db32ddf91abc7@plan9.ucalgary.ca \
--to=mirtchov@cpsc.ucalgary.ca \
--cc=9fans@cse.psu.edu \
/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).