lkml.org 
[lkml]   [1999]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: accept() doesn't block as it should in 2.3.x kernels
Thanks,
I reread the man page and see that the sa2_len parameter
to accept is value-result, and I should have initialized.

I missed it in my attempt to hack c code from the perl example.
Next time I'll compare the straces before I submit, but as
Pete points out, the problem is still there.

Thanks to all the readers for their comments,
David Dyck


On Sun, 12 Dec 1999, Pete Wyckoff wrote:

> root@chaos.analogic.com said:
> > > if (listen(s, 5) == -1) { perror("listen"); exit(1); }
> > >
> > > {
> > > int s2;
> > > int sa2_len;
> > > struct sockaddr_un sa2;
> > >
> >
> > Here, the length of sa2, passed to accept via sa2_len is undefined.
> >
> >
> > The length should be initialized to the length of the structure so
> > accept() knows how much space is available. Accept() is probably
> > getting a 0, returning a bogus error-code.
> >
> > > if ((s2=accept(s, (struct sockaddr *)&sa2, &sa2_len)) == -1)
> > > {perror("accept didn't block"); exit(1); }
> > > }
> > >
> >
> >
> > Cheers,
> > Dick Johnson
>
> Yes, sa2_len should be initialized. No, accept() does the right thing
> if it gets a bogus length (EINVAL). A zero length results in no copy
> into sa2, but the syscall completes without error. Read the source.
>
> -- Pete
>


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:1.107 / U:1.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site