9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] devip connect error state
@ 2007-08-08 20:59 Eric Van Hensbergen
  2007-08-08 21:14 ` ron minnich
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Eric Van Hensbergen @ 2007-08-08 20:59 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs; +Cc: inferno-list

So -- in devip on Inferno hosted we have this bit of code: (connectctlmsg)

       if(c->state != Idle)
                error(Econinuse);
        c->state = Connecting;
        ...
        if(waserror()){
                qlock(&c->l);
                c->state = Connected;   /* sic */
                nexterror();
        }
        /* p = x->connect(c, cb->f, cb->nf); */
        so_connect(c->sfd, ip6w(c->raddr), c->rport);
        qlock(&c->l);
        poperror();

In native inferno (and Plan 9) devip we have this bit of code:
        if(c->state != 0)
                error(Econinuse);
        c->state = Connecting;
        ...
        if(waserror()){
                qlock(c);
                nexterror();
        }
        sleep(&c->cr, connected, c);
        qlock(c);
        poperror();

------------------

The result being if the connect fails, the state remains Connecting,
and subsequent writes of 'connect' commands fail because Econinuse.

In Plan 9/Inferno, this doesn't really matter much because if dial(2)
fails we close the fd to the ctl file.

Now in the Libra library OS stuff that I've been working on, we are
using a slight different (more socket-ish) semantic.  There's nothing
in the devip man pages that say that I can't issue new commands to the
ctl file after a failed command.

So, bug or feature?  At the very least it would seem a good idea to
set c->state to Hungup (and also change the c->state != 0 to a
c->state != Idle).  I have no idea why we set c->state to Connected in
Inferno hosted -- that just seems completely bonkers.

             -eric


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] devip connect error state
  2007-08-08 20:59 [9fans] devip connect error state Eric Van Hensbergen
@ 2007-08-08 21:14 ` ron minnich
  2007-08-08 21:19 ` Charles Forsyth
  2007-08-08 21:48 ` Charles Forsyth
  2 siblings, 0 replies; 7+ messages in thread
From: ron minnich @ 2007-08-08 21:14 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs; +Cc: inferno-list

On 8/8/07, Eric Van Hensbergen <ericvh@gmail.com> wrote:

> So, bug or feature?  At the very least it would seem a good idea to
> set c->state to Hungup (and also change the c->state != 0 to a
> c->state != Idle).  I have no idea why we set c->state to Connected in
> Inferno hosted -- that just seems completely bonkers.

It actually looks like a cut and paste error -- cut, paste, forget to
change the rvalue.

ron


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] devip connect error state
  2007-08-08 20:59 [9fans] devip connect error state Eric Van Hensbergen
  2007-08-08 21:14 ` ron minnich
@ 2007-08-08 21:19 ` Charles Forsyth
  2007-08-09  3:33   ` Eric Van Hensbergen
  2007-08-08 21:48 ` Charles Forsyth
  2 siblings, 1 reply; 7+ messages in thread
From: Charles Forsyth @ 2007-08-08 21:19 UTC (permalink / raw)
  To: 9fans

> c->state != Idle).  I have no idea why we set c->state to Connected in
> Inferno hosted -- that just seems completely bonkers.

the /* sic */ tells you that yes, it looks odd, but it's meant that way.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] devip connect error state
  2007-08-08 20:59 [9fans] devip connect error state Eric Van Hensbergen
  2007-08-08 21:14 ` ron minnich
  2007-08-08 21:19 ` Charles Forsyth
@ 2007-08-08 21:48 ` Charles Forsyth
  2 siblings, 0 replies; 7+ messages in thread
From: Charles Forsyth @ 2007-08-08 21:48 UTC (permalink / raw)
  To: 9fans

> The result being if the connect fails, the state remains Connecting,
> and subsequent writes of 'connect' commands fail because Econinuse.
> 
> In Plan 9/Inferno, this doesn't really matter much because if dial(2)
> fails we close the fd to the ctl file.
> 
> Now in the Libra library OS stuff that I've been working on, we are
> using a slight different (more socket-ish) semantic.  There's nothing
> in the devip man pages that say that I can't issue new commands to the
> ctl file after a failed command.

i imagine that on at least one of the platforms on which the code runs,
``socket-ish semantics'' are not as well-defined as you think, and the
underlying fd goes into a peculiar state when the connect fails.
it's not in fact hung up, but you can't connect again. i think
the code's choosing an existing state (i suppose it ought to have
added a new state Buggered, except that sets off the spam filters) that
blocks further connection requests but allows some interaction with
the fd.  (i don't know why, yet.)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] devip connect error state
  2007-08-08 21:19 ` Charles Forsyth
@ 2007-08-09  3:33   ` Eric Van Hensbergen
  2007-08-09  6:47     ` Bruce Ellis
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Van Hensbergen @ 2007-08-09  3:33 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 8/8/07, Charles Forsyth <forsyth@terzarima.net> wrote:
> > c->state != Idle).  I have no idea why we set c->state to Connected in
> > Inferno hosted -- that just seems completely bonkers.
>
> the /* sic */ tells you that yes, it looks odd, but it's meant that way.
>

I kinda figured, but I was still left wondering why?

          -eric


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] devip connect error state
  2007-08-09  3:33   ` Eric Van Hensbergen
@ 2007-08-09  6:47     ` Bruce Ellis
  2007-08-09  8:38       ` Charles Forsyth
  0 siblings, 1 reply; 7+ messages in thread
From: Bruce Ellis @ 2007-08-09  6:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

c'mon eric.  "why?" when it comes to sockets has always been
swept under the carpet for all known functionality.

brucee

On 8/9/07, Eric Van Hensbergen <ericvh@gmail.com> wrote:
> On 8/8/07, Charles Forsyth <forsyth@terzarima.net> wrote:
> > > c->state != Idle).  I have no idea why we set c->state to Connected in
> > > Inferno hosted -- that just seems completely bonkers.
> >
> > the /* sic */ tells you that yes, it looks odd, but it's meant that way.
> >
>
> I kinda figured, but I was still left wondering why?
>
>          -eric
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] devip connect error state
  2007-08-09  6:47     ` Bruce Ellis
@ 2007-08-09  8:38       ` Charles Forsyth
  0 siblings, 0 replies; 7+ messages in thread
From: Charles Forsyth @ 2007-08-09  8:38 UTC (permalink / raw)
  To: 9fans

>"why?" when it comes to sockets has always been
>swept under the carpet for all known functionality.

one surprise for me is that linux locks the socket
during i/o (good), but releases it in certain cases, so
writes from several processes are interleaved every so often (bad),
so it might just as well not bother with the overall lock anyway.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-08-09  8:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-08 20:59 [9fans] devip connect error state Eric Van Hensbergen
2007-08-08 21:14 ` ron minnich
2007-08-08 21:19 ` Charles Forsyth
2007-08-09  3:33   ` Eric Van Hensbergen
2007-08-09  6:47     ` Bruce Ellis
2007-08-09  8:38       ` Charles Forsyth
2007-08-08 21:48 ` Charles Forsyth

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