Hi,

I'm looking at the code now -- definitely needs to be SOCKET in nsd.h. The 
reason can be seen in ns_sockpair in fd/sock.c where the code for a socket pair 
is done.  It's just a wrapper around Unix socketpair() but has a bunch of extra 
code to do the loopback-connect thing on Windows.  The "socks" are passed by 
reference -- this code thinks it's 16 bytes (i.e., 2 8-byte long ints) but it's 
getting 2 4-bytes from the trigger in the driver code.  It's could be 
overwriting some more of the driver structure -- not clear.  Note that ns_pipe 
!= ns_sockpair.  An ns_pipe is used to create process pipelines with the lib-c 
code on Windows.  On Windows, it can't be used a s trigger pipe.

The fix should be just updating nsd.h with SOCKET.  I'd do it but I don't have 
any of my dev environment setup -- something I was going to finally dig into in 
a few weeks.  Anyone else with commit could handle the code update.  Compiling 
and testing on 64-bit Windows would be more work and require the Visual Studio 
stuff -- the Express C++ stuff appears to only support 32-bit.


BTW:  The basic strategy for Windows was to make it look as much like Unix as 
possible, as lightly as possible.  This is why you get some weirdness like the 
opendir/readdir/closedir emulation code stuffed in the Windows thread library 
(nsthread/winthread.c).  There's also quite a bit of ifdef WIN stuff in the 
process exec code (nsd/exec.c) and some file management code (nsd/fd.c).  The 
use of trigger pipes is a Unix way of monitoring events -- I think on Windows 
you could "WaitForMultipleHandles" with all sorts of things, including network 
and process sync stuff, but since the goal was to be Unix-like, instead of 
modifying the event-driven code to eliminate socketpair's for wakeup, this 
ns_sockpair emulation was used instead.

Also, in later versions Windows was being ignored -- you see this in the 
oversight of SOCKET for the driver trigger we've been talking about and the 
NsMap code not yet implemented for Windows.  I agree a scan of all SOCKETs not 
being declared are SOCKET's makes good sense.  

-Jim






On Aug 4, 2011, at 8:28 AM, Maurizio Martignano wrote:

> It is not a matter of understanding
> It is a matter of testing
>  
> On Windows 64 int trigger[2] doesn’t work whereas SOCKET trigger[2] does work.
>  
> On top of that in several other places SOCKET has been used, so if for no 
> other reason, I suggest one of the code maintainers takes a proper walk on 
> the code base and make sure that all sockets are SOCKET sockets and not int 
> sockets…
>  
> Ciao,
> Maurizio
>  
>  
> From: AOLserver Discussion [mailto:[email protected]] On Behalf Of 
> Dossy Shiobara
> Sent: 04 August 2011 15:51
> To: [email protected]
> Subject: Re: [AOLSERVER] Aolserver Progress - Some few examples....
>  
> It's probably safer to define this as SOCKET, but windows.h says SOCKET is:
> 
> typedef u_int           SOCKET;
> 
> And:
> 
> typedef unsigned int    u_int;
> 
> Since Windows is LLP64 and most Unix-like systems are LP64, I don't 
> understand how AOLserver's defining trigger[2] as (int) is the problem -- 
> Windows might complain about some signed/unsigned thing at compile time, but 
> in both cases, (int) is 32 bits.
> 
> 
> On 8/4/11 3:24 AM, Maurizio Martignano wrote:
>     int        trigger[2];               /* Wakeup trigger pipe. */ ß Why is 
> this an int when it was a SOCKET (any justification????)
> 
> 
> -- 
> Dossy Shiobara         |      "He realized the fastest way to change
> [email protected]     |   is to laugh at your own folly -- then you
> http://panoptic.com/   |   can let go and quickly move on." (p. 70) 
>   * WordPress * jQuery * MySQL * Security * Business Continuity *
>  
>  
> 
> --
> 
> AOLserver - http://www.aolserver.com/
> 
>  
> 
> To Remove yourself from this list, simply send an email to 
> <[email protected]> with the
> 
> body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
> field of your email blank.
> 
> 
> --
> AOLserver - http://www.aolserver.com/
> 
> 
> To Remove yourself from this list, simply send an email to 
> <[email protected]> with the
> body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
> field of your email blank.
> 



--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
<[email protected]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to