mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-27 07:54:50 +02:00
2-29 5
This commit is contained in:
parent
afbfa98759
commit
a4163ba0a3
@ -216,6 +216,7 @@ void socket_syncio_tests()
|
|||||||
TEST_START("basic recv s->c");
|
TEST_START("basic recv s->c");
|
||||||
ret = recv(connect_fd, small_recv_buf, SMALL_RECV_BUF_SIZE, 0);
|
ret = recv(connect_fd, small_recv_buf, SMALL_RECV_BUF_SIZE, 0);
|
||||||
ASSERT_INT_EQ(ret, strlen(small_send_buf));
|
ASSERT_INT_EQ(ret, strlen(small_send_buf));
|
||||||
|
small_recv_buf[ret] = '\0';
|
||||||
ASSERT_STRING_EQ(small_send_buf, small_recv_buf);
|
ASSERT_STRING_EQ(small_send_buf, small_recv_buf);
|
||||||
memset(small_recv_buf, 0, sizeof(small_recv_buf));
|
memset(small_recv_buf, 0, sizeof(small_recv_buf));
|
||||||
TEST_DONE();
|
TEST_DONE();
|
||||||
@ -225,6 +226,7 @@ void socket_syncio_tests()
|
|||||||
ASSERT_INT_EQ(ret, strlen(small_send_buf));
|
ASSERT_INT_EQ(ret, strlen(small_send_buf));
|
||||||
ret = recv(accept_fd, small_recv_buf, SMALL_RECV_BUF_SIZE, 0);
|
ret = recv(accept_fd, small_recv_buf, SMALL_RECV_BUF_SIZE, 0);
|
||||||
ASSERT_INT_EQ(ret, strlen(small_send_buf));
|
ASSERT_INT_EQ(ret, strlen(small_send_buf));
|
||||||
|
small_recv_buf[ret] = '\0';
|
||||||
ASSERT_STRING_EQ(small_send_buf, small_recv_buf);
|
ASSERT_STRING_EQ(small_send_buf, small_recv_buf);
|
||||||
memset(small_recv_buf, 0, sizeof(small_recv_buf));
|
memset(small_recv_buf, 0, sizeof(small_recv_buf));
|
||||||
TEST_DONE();
|
TEST_DONE();
|
||||||
|
@ -13,23 +13,18 @@
|
|||||||
|
|
||||||
static int errno_from_WSAError(int wsaerrno)
|
static int errno_from_WSAError(int wsaerrno)
|
||||||
{
|
{
|
||||||
|
switch (wsaerrno) {
|
||||||
if (wsaerrno == WSAEWOULDBLOCK)
|
case WSAEWOULDBLOCK:
|
||||||
{
|
|
||||||
return EAGAIN;
|
return EAGAIN;
|
||||||
}
|
case WSAEFAULT:
|
||||||
|
|
||||||
if (wsaerrno == WSAEFAULT)
|
|
||||||
{
|
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
}
|
case WSAEINVAL:
|
||||||
|
|
||||||
if (wsaerrno == WSAEINVAL)
|
|
||||||
{
|
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
case WSAESHUTDOWN:
|
||||||
|
return ECONNRESET;
|
||||||
|
default:
|
||||||
|
return wsaerrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wsaerrno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int socketio_initialize() {
|
int socketio_initialize() {
|
||||||
@ -271,9 +266,19 @@ int socketio_recv(struct w32_io* pio, void *buf, size_t len, int flags) {
|
|||||||
|
|
||||||
//if io is already pending
|
//if io is already pending
|
||||||
if (pio->read_details.pending) {
|
if (pio->read_details.pending) {
|
||||||
errno = EAGAIN;
|
//if recv is now in blocking mode, wait for data to be available
|
||||||
debug2("Read is already pending, io:%p", pio);
|
if (w32_io_is_blocking(pio)) {
|
||||||
return -1;
|
debug2("socket was previously non-blocing but now in blocking mode, waiting for io");
|
||||||
|
while (socketio_is_io_available(pio, TRUE) == FALSE) {
|
||||||
|
if (0 != wait_for_any_event(NULL, 0, INFINITE))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errno = EAGAIN;
|
||||||
|
debug2("Read is already pending, io:%p", pio);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if we have some buffer copy it and return #bytes copied
|
//if we have some buffer copy it and return #bytes copied
|
||||||
|
Loading…
x
Reference in New Issue
Block a user