* fhandler_socket.cc (fhandler_socket::sendto): Drop out of loop if
has_been_closed gets set. (fhandler_socket::sendmsg): Ditto. * net.cc (wsock_event::wait): Don't initialize evts. Don't try to evaluate network events if WSAEnumNetworkEvents fails. (wsock_event::release): Save last WSA error and set it again unless resetting to blocking socket fails. * wsock_event.h (class wsock_event): Remove destructor.
This commit is contained in:
parent
fbba4780af
commit
54aefcc6bc
|
@ -1,3 +1,14 @@
|
|||
2004-04-01 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler_socket.cc (fhandler_socket::sendto): Drop out of loop if
|
||||
has_been_closed gets set.
|
||||
(fhandler_socket::sendmsg): Ditto.
|
||||
* net.cc (wsock_event::wait): Don't initialize evts. Don't try to
|
||||
evaluate network events if WSAEnumNetworkEvents fails.
|
||||
(wsock_event::release): Save last WSA error and set it again unless
|
||||
resetting to blocking socket fails.
|
||||
* wsock_event.h (class wsock_event): Remove destructor.
|
||||
|
||||
2004-03-31 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler_tape.cc (mtinfo::initialize): Fix fatal error message.
|
||||
|
|
|
@ -953,7 +953,8 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
|
|||
break;
|
||||
}
|
||||
}
|
||||
while (!(res = wsock_evt.wait (get_socket (), has_been_closed)));
|
||||
while (!(res = wsock_evt.wait (get_socket (), has_been_closed))
|
||||
&& !has_been_closed);
|
||||
wsock_evt.release (get_socket ());
|
||||
}
|
||||
}
|
||||
|
@ -1088,7 +1089,8 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot)
|
|||
break;
|
||||
}
|
||||
}
|
||||
while (!(res = wsock_evt.wait (get_socket (), has_been_closed)));
|
||||
while (!(res = wsock_evt.wait (get_socket (), has_been_closed))
|
||||
&& !has_been_closed);
|
||||
wsock_evt.release (get_socket ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,32 +75,33 @@ wsock_event::wait (int sock, int &closed)
|
|||
{
|
||||
case WSA_WAIT_EVENT_0:
|
||||
WSANETWORKEVENTS evts;
|
||||
memset (&evts, 0, sizeof evts);
|
||||
WSAEnumNetworkEvents (sock, event, &evts);
|
||||
if (evts.lNetworkEvents & FD_READ)
|
||||
if (!WSAEnumNetworkEvents (sock, event, &evts))
|
||||
{
|
||||
if (evts.iErrorCode[FD_READ_BIT])
|
||||
wsa_err = evts.iErrorCode[FD_READ_BIT];
|
||||
else
|
||||
ret = 0;
|
||||
if (evts.lNetworkEvents & FD_READ)
|
||||
{
|
||||
if (evts.iErrorCode[FD_READ_BIT])
|
||||
wsa_err = evts.iErrorCode[FD_READ_BIT];
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
else if (evts.lNetworkEvents & FD_WRITE)
|
||||
{
|
||||
if (evts.iErrorCode[FD_WRITE_BIT])
|
||||
wsa_err = evts.iErrorCode[FD_WRITE_BIT];
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
if (evts.lNetworkEvents & FD_CLOSE)
|
||||
{
|
||||
closed = 1;
|
||||
if (!wsa_err && evts.iErrorCode[FD_CLOSE_BIT])
|
||||
wsa_err = evts.iErrorCode[FD_CLOSE_BIT];
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
if (wsa_err)
|
||||
WSASetLastError (wsa_err);
|
||||
}
|
||||
else if (evts.lNetworkEvents & FD_WRITE)
|
||||
{
|
||||
if (evts.iErrorCode[FD_WRITE_BIT])
|
||||
wsa_err = evts.iErrorCode[FD_WRITE_BIT];
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
if (evts.lNetworkEvents & FD_CLOSE)
|
||||
{
|
||||
closed = 1;
|
||||
if (!wsa_err && evts.iErrorCode[FD_CLOSE_BIT])
|
||||
wsa_err = evts.iErrorCode[FD_CLOSE_BIT];
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
if (wsa_err)
|
||||
WSASetLastError (wsa_err);
|
||||
break;
|
||||
case WSA_WAIT_EVENT_0 + 1:
|
||||
WSASetLastError (WSAEINTR);
|
||||
|
@ -114,10 +115,14 @@ wsock_event::wait (int sock, int &closed)
|
|||
void
|
||||
wsock_event::release (int sock)
|
||||
{
|
||||
int last_err = WSAGetLastError ();
|
||||
WSAEventSelect (sock, event, 0);
|
||||
WSACloseEvent (event);
|
||||
unsigned long non_block = 0;
|
||||
ioctlsocket (sock, FIONBIO, &non_block);
|
||||
if (ioctlsocket (sock, FIONBIO, &non_block))
|
||||
debug_printf ("return to blocking failed: %d", WSAGetLastError ());
|
||||
else
|
||||
WSASetLastError (last_err);
|
||||
}
|
||||
|
||||
WSADATA wsadata;
|
||||
|
|
|
@ -16,12 +16,6 @@ class wsock_event
|
|||
WSAEVENT event;
|
||||
public:
|
||||
wsock_event () : event (NULL) {};
|
||||
~wsock_event ()
|
||||
{
|
||||
if (event)
|
||||
WSACloseEvent (event);
|
||||
event = NULL;
|
||||
};
|
||||
|
||||
/* The methods are implemented in net.cc */
|
||||
bool prepare (int sock, long event_mask);
|
||||
|
|
Loading…
Reference in New Issue