[Spread-users] [BUG][PATCH] fd to session troubles

Jonathan Stanton jonathan at cnds.jhu.edu
Mon Feb 4 21:51:10 EST 2002


Thanks to all of you for your help. 

I've committed to cvs the approach described below. I've compiled and
tested the code on Linux, BSDI, FreeBSD and IRIX, but I can't even try to
compile the all important Windows platform until I get into the lab
tomorrow. When you get a chance, take a look at the patch (it is in the
spreadcvs mailing list archives if you aren't subscribed) or check it out
of cvs and tell me what you think.

The approach, mostly based on the suggestions on the list.

All use of errno for sockets related things has been changed to use
sock_errno to access the error, sock_set_errno to set the error, and
sock_strerror to print a string representation of the error. The one place
that we use errno in reference to stdio FILE io, I left it as errno as that
is part of standard C. 

The arch.h file defines sock_errno, sock_set_errno, sock_strerror for each
platform to the appropriate default. 

For unix: errno, sock_unix_set_errno, strerror (sock_unix_set_errno is a
macro that just asigns to errno)

For Windows: WSAGetLastError(), WSASetLastError, sock_strerror (an
implementation of this is provided in arch.c because we could not find an
Winsock equivelent to strerror)

Since we never use the EAGAIN, E* error constants for anything besides
network sockets, for Windows I redefine EAGAIN, EWOULDBLOCK, EINTR to the
WSA equivelents. If we start needing the real versions (for standard IO) on
windows then this will have to be revisited as the numbers of the WSA and E
varients may not be the same.

For platforms with only one of EAGAIN or EWOULDBLOCK I test for both and
make sure both are defined, then test for both in the code. I know this
adds an extra test to the code, but for now I prefer that to possibly
breaking a platform with different constant numbers for the two errors.
This should be easy to fix later if it proves unnecessary.

Jonathan

-- 
-------------------------------------------------------
Jonathan R. Stanton         jonathan at cs.jhu.edu
Dept. of Computer Science   
Johns Hopkins University    
-------------------------------------------------------





More information about the Spread-users mailing list