mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-24 22:45:17 +02:00
2-28 C5
This commit is contained in:
parent
6c4b701dd6
commit
ef3f1691e8
@ -74,6 +74,9 @@ int socket_prepare(char* ip)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define READ_BUf_SIZE 1024 * 1024 * 2
|
||||||
|
#define WRITE_BUF_SIZE 1024 * 1024 * 5
|
||||||
|
|
||||||
namespace UnitTests
|
namespace UnitTests
|
||||||
{
|
{
|
||||||
TEST_CLASS(SocketIOTests)
|
TEST_CLASS(SocketIOTests)
|
||||||
@ -99,7 +102,7 @@ namespace UnitTests
|
|||||||
w32posix_done();
|
w32posix_done();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD(TestMethod1)
|
TEST_METHOD(socketio)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = socket_prepare("::1");
|
ret = socket_prepare("::1");
|
||||||
@ -117,10 +120,9 @@ namespace UnitTests
|
|||||||
set_nonblock(c);
|
set_nonblock(c);
|
||||||
set_nonblock(s);
|
set_nonblock(s);
|
||||||
|
|
||||||
#define WRITE_BUF_SIZE 1024 * 1024 * 5
|
char *to_write = (char*)malloc(WRITE_BUF_SIZE); //5MB
|
||||||
char to_write[1024 * 1024 * 5]; //5MB
|
|
||||||
#define READ_BUf_SIZE 1024 * 1024 * 2
|
char *read_to = (char*)malloc(READ_BUf_SIZE); //2MB
|
||||||
char read_to[READ_BUf_SIZE]; //2MB
|
|
||||||
|
|
||||||
//write from c, read from s
|
//write from c, read from s
|
||||||
fd_set read_set;
|
fd_set read_set;
|
||||||
@ -177,7 +179,7 @@ namespace UnitTests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Assert::AreEqual(bytes_written, bytes_read, L"", LINE_INFO());
|
Assert::AreEqual((bytes_written == bytes_read)? 1:0, TRUE, L"", LINE_INFO());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD(TestMethod)
|
TEST_METHOD(TestMethod)
|
||||||
|
@ -716,8 +716,7 @@ int socketio_connect(struct w32_io* pio, const struct sockaddr* name, int namele
|
|||||||
|
|
||||||
//close event handle
|
//close event handle
|
||||||
CloseHandle(pio->write_overlapped.hEvent);
|
CloseHandle(pio->write_overlapped.hEvent);
|
||||||
pio->write_overlapped.hEvent = 0;
|
|
||||||
|
|
||||||
if (pio->write_details.error) {
|
if (pio->write_details.error) {
|
||||||
errno = errno_from_WSAError(pio->write_details.error);
|
errno = errno_from_WSAError(pio->write_details.error);
|
||||||
debug("ERROR: async io completed with error: %d, io:%p", errno, pio);
|
debug("ERROR: async io completed with error: %d, io:%p", errno, pio);
|
||||||
@ -726,12 +725,14 @@ int socketio_connect(struct w32_io* pio, const struct sockaddr* name, int namele
|
|||||||
|
|
||||||
if (0 != setsockopt(pio->sock, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, NULL, 0))
|
if (0 != setsockopt(pio->sock, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, NULL, 0))
|
||||||
{
|
{
|
||||||
|
int i = WSAGetLastError();
|
||||||
errno = errno_from_WSALastError();
|
errno = errno_from_WSALastError();
|
||||||
debug("ERROR: setsockopt failed:%d, io:%p", errno, pio);
|
debug("ERROR: setsockopt failed:%d, io:%p", errno, pio);
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Reset any state used during connect
|
||||||
|
ZeroMemory(&pio->write_details, sizeof(pio->write_details));
|
||||||
pio->type = SOCK_FD;
|
pio->type = SOCK_FD;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ BOOL w32_io_is_blocking(struct w32_io* pio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOL w32_io_is_io_available(struct w32_io* pio, BOOL rd) {
|
BOOL w32_io_is_io_available(struct w32_io* pio, BOOL rd) {
|
||||||
if ((pio->type == LISTEN_FD) || (pio->type == SOCK_FD)) {
|
if (pio->type <= SOCK_FD) {
|
||||||
return socketio_is_io_available(pio, rd);
|
return socketio_is_io_available(pio, rd);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
//order to be maintained
|
||||||
enum w32_io_type {
|
enum w32_io_type {
|
||||||
UNKOWN_FD = 0,
|
UNKOWN_FD = 0,
|
||||||
LISTEN_FD,
|
LISTEN_FD,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user