This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Workaround patch for MS CLOSE_WAIT bug


On Mon, Apr 15, 2002 at 09:51:33AM -0400, Pierre A. Humblet wrote:
> Corinna Vinschen wrote:
> > 
> > Your patch looks good. What I didn't quite get is, how the
> > code now looks like (ideally) when using the new FD_SETCF 
> > functionality.
> 
> See 4 lines below not starting with > > 
> > > int oldsocks[2^32];  /* I'll be smarter */
> > > sock = socket()     
> fcntl(sock, F_SETCF, 0)  (1)
> > > bind(sock)
> > > listen(sock)
> > > while (1) {
> > >  select()
> > >  newsock = accept(sock)
> > >  pid = fork()
> > >  if (pid == 0) {
> /*    close(sock)   */   (2)
> > >     child works
> > >  }
> > >  if (pid > 0) {
> > >     oldsocks[pid] = newsock
> fcntl(newsock, F_SETCF, 0) (3)
> > >  }
> > > }
> > > sigchild_handler()
> > > {
> > >   pid = waitpid()
> shutdown(oldsocks[pid], 2) (4)
> > >   close(oldsocks[pid]) 

Sorry if I'm dense but... shouldn't the new FD_SETCF functionality
allow to do the "right thing" without adding the oldsocks variable
at all?!?  You wrote about the disadvantage that the child inherits
that array...

> By the way, is it safe to call shutdown() & close() directly
> from a handler?

It should.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]