From: john AT exmachina DOT net (John Mullee) Subject: forked child inherits socket: bug? (MetaHTML-5.09 with cygwin-b20) 24 Nov 1998 07:50:58 -0800 Message-ID: <36599F85.BCFDCF24.cygnus.gnu-win32@exmachina.net> References: <199811232351 DOT PAA01387 AT carraig DOT oisin DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: jarlath AT oisin DOT com, metahtml-users AT metahtml DOT com, gnu-win32 AT cygnus DOT com jarlath AT oisin DOT com wrote: > > Hey John, > > Thanks VERY much for this info. it will be very helpful in getting to Bad news, I'm afraid. It seems that the current forking mechanism in cygwin loses inherited sockets. This is my current theory, anyway.. A sniff of the net io for mhttpd looks something like: CLI: syn SRV: syn ack CLI: ack CLI: push ".. POST blah blah .." CLI: push ".. blah" (post in 2 packets) SRV: " .. 302 found .." SRV: RESET (other packets of response not sent) SRV: RESET My telnet investigations see the input-stream closed after the first packet ( shutdown(connection,1); ? ), after which the server sends one packet, then 2 resets. So I'm theorising that: a) The server parent process accept()'s the first packet b) parent forks a child, which inherits the connection I'm not sure if the child is expected to finish reading the client input stream here, or what. It doesn't, anyway.. c) parent closes the connection (server.c:1130) d) cygwin starts new process, copies datasegments, re-initialises dlls Because cygwin now only loads the socket-io dll on demand, I guess the the dll initialisation routines differ. deserves more investigation.. e) child sends a first packet f) child sends a reset. This implies that the stack somehow lost the session, probably because the parent was time-sliced, during which time it closed the connection, causing the client's next write to result in a reset. I could be way off the mark here; take this with a pinch of salt, just guessing really. Deserves some test-case code, sorry I don't have time ... g) child sends a _second_ reset. maybe provoked by it's attempt to perform a close operation, or a send a second packet. A test-case that forks a child expecting an inherited tcp connection should be easy enough to devise. I tried loading the mod_metahtml in apache, but I've had some difficulty with the fact that the win32 relase of apache and cygwin use different build tools.. somebody has 'ported' the apache unix source tree to cygwin, or at least they did for cyg-beta-19, but I havn't tried this. I also had trouble, specifically, with lots of hidden path-dependancies in metahtml (sometimes ${prefix}, sometimes '/www' all over the place), so at this point I decided that I'd be much better off running linux. Recommend an ODBC driver for linux? John - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".