]> git.michaelhowe.org Git - packages/o/openafs.git/commit
Rx: Fix socket() handling so errors are properly detected
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 21 Oct 2010 18:23:18 +0000 (14:23 -0400)
committerDerrick Brashear <shadow@dementia.org>
Tue, 26 Oct 2010 02:22:37 +0000 (19:22 -0700)
commit30308fd6e4f6f142ccfde96bc69348bca6574847
tree9101c2574152a3893fa6e88bd2c902e03e910843
parent72bda3acbc2f610deebddeeec3a152691f028aa4
Rx: Fix socket() handling so errors are properly detected

socket() returns an osi_socket which on Windows is an
unsigned type (HANDLE).  Therefore, tests of osi_socket < 0
will never identify when the INVALID_SOCKET value is returned.
On Windows, the OSI_NULLSOCKET is assigned to INVALID_SOCKET.
Replace all comparisons of (osi_socket < 0) with
(osi_socket == OSI_NULLSOCKET) as a means of detecting errors.

In addition, do not pass socket() the protocol value 0 when
IPPROTO_UDP is what is desired.

Finally, perror() on Windows never reports any error from Winsock.
perror() is a CRT function.  To get the real socket error
WSAGetLastError() must be called and its value be written to
stderr.

Reviewed-on: http://gerrit.openafs.org/3027
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
(cherry picked from commit c8f47626e2428449bfb64844e46fe5ad6b8e0f1c)
Change-Id: Ib9aada7b549e661eaf965747011ffbe85e306d4d
Reviewed-on: http://gerrit.openafs.org/3125
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/rx/rx_user.c
src/rxdebug/rxdebug.c