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


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]) 
> > }
> Could you write a short example?  If inetd (what about sshd?) could
> benefit, I'd like to see how to do it.  Btw., the sources are in the
> inetutils-1.3.2-17-src.tar.bz2 file, obviously, which you can get
> by using setup.exe.
Silly me. I got fooled by the n/a[available?/applicable?] acronym
in setup. OK, I'll look at it in the coming days.
By the way, is it safe to call shutdown() & close() directly
from a handler?

Pierre


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