4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 12:29:32 +08:00

* fhandler_socket.cc (fhandler_socket::recvfrom): Initialize res to

SOCKET_ERROR.  Use SOCKET_ERROR instead of -1 throughout.
	(fhandler_socket::recvmsg): Ditto.
	(fhandler_socket::sendto): Ditto.
	(fhandler_socket::sendmsg): Ditto.
	* net.cc (wsock_event::prepare): Call WSASetLastError instead of
	SetLastError.
	(wsock_event::wait): Use SOCKET_ERROR instead of -1.
This commit is contained in:
Corinna Vinschen 2004-03-31 09:13:54 +00:00
parent ed4c5eceb0
commit 4450172a6c
3 changed files with 23 additions and 21 deletions

View File

@ -1,3 +1,14 @@
2004-03-31 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::recvfrom): Initialize res to
SOCKET_ERROR. Use SOCKET_ERROR instead of -1 throughout.
(fhandler_socket::recvmsg): Ditto.
(fhandler_socket::sendto): Ditto.
(fhandler_socket::sendmsg): Ditto.
* net.cc (wsock_event::prepare): Call WSASetLastError instead of
SetLastError.
(wsock_event::wait): Use SOCKET_ERROR instead of -1.
2004-03-30 Thomas Pfaff <tpfaff@gmx.net>
* thread.h (pthread::init_mainthread): Add parameter forked. Set

View File

@ -714,7 +714,7 @@ int
fhandler_socket::recvfrom (void *ptr, size_t len, int flags,
struct sockaddr *from, int *fromlen)
{
int res;
int res = SOCKET_ERROR;
DWORD ret;
flags &= MSG_WINMASK;
@ -728,8 +728,7 @@ fhandler_socket::recvfrom (void *ptr, size_t len, int flags,
if (is_nonblocking () || has_been_closed)
res = WSARecvFrom (get_socket (), &wsabuf, 1, &ret, (DWORD *) &flags,
from, fromlen,
NULL, NULL);
from, fromlen, NULL, NULL);
else
{
wsock_event wsock_evt;
@ -758,7 +757,6 @@ fhandler_socket::recvfrom (void *ptr, size_t len, int flags,
if (WSAGetLastError () == WSAEMSGSIZE)
return len;
res = -1;
set_winsock_errno ();
}
else
@ -786,7 +784,7 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot)
struct sockaddr *from = (struct sockaddr *) msg->msg_name;
int *fromlen = from ? &msg->msg_namelen : NULL;
int res;
int res = SOCKET_ERROR;
if (!winsock2_active)
{
@ -812,7 +810,7 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot)
if (!buf)
{
set_errno (ENOMEM);
res = -1;
res = SOCKET_ERROR;
}
else
{
@ -885,7 +883,6 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot)
if (WSAGetLastError () == WSAEMSGSIZE)
return len;
res = -1;
set_winsock_errno ();
}
else
@ -921,7 +918,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
if (to && !get_inet_addr (to, tolen, &sin, &tolen))
return -1;
int res;
int res = SOCKET_ERROR;
DWORD ret;
if (!winsock2_active)
@ -964,10 +961,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
}
if (res == SOCKET_ERROR)
{
res = -1;
set_winsock_errno ();
}
else
res = ret;
@ -976,7 +970,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
EPIPE is generated if the local end has been shut down on a connection
oriented socket. In this case the process will also receive a SIGPIPE
unless MSG_NOSIGNAL is set. */
if (res == -1 && get_errno () == ESHUTDOWN
if (res == SOCKET_ERROR && get_errno () == ESHUTDOWN
&& get_socket_type () == SOCK_STREAM)
{
set_errno (EPIPE);
@ -1002,7 +996,7 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot)
struct iovec *const iov = msg->msg_iov;
const int iovcnt = msg->msg_iovlen;
int res;
int res = SOCKET_ERROR;
if (!winsock2_active)
{
@ -1029,7 +1023,7 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot)
if (!buf)
{
set_errno (ENOMEM);
res = -1;
res = SOCKET_ERROR;
}
else
{
@ -1101,10 +1095,7 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot)
}
if (res == SOCKET_ERROR)
{
res = -1;
set_winsock_errno ();
}
else
res = ret;
}

View File

@ -53,7 +53,7 @@ extern "C"
bool
wsock_event::prepare (int sock, long event_mask)
{
SetLastError (0);
WSASetLastError (0);
if ((event = WSACreateEvent ()) != WSA_INVALID_EVENT
&& WSAEventSelect (sock, event, event_mask) == SOCKET_ERROR)
{
@ -67,7 +67,7 @@ wsock_event::prepare (int sock, long event_mask)
int
wsock_event::wait (int sock, int &closed)
{
int ret = -1;
int ret = SOCKET_ERROR;
DWORD wsa_err = 0;
WSAEVENT ev[2] = { event, signal_arrived };
switch (WSAWaitForMultipleEvents (2, ev, FALSE, WSA_INFINITE, FALSE))