diff options
author | Matt Caswell <matt@openssl.org> | 2015-11-13 11:22:21 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-11-20 23:37:17 +0000 |
commit | 2b2c78d4f0a73498739cfc0879299d7325c35160 (patch) | |
tree | 2ed0601fe6fa8482bca8646a8cc0b290386e48f4 /crypto/async/arch | |
parent | e38565f536b7674ef507564b5c646712b1d7eed4 (diff) | |
download | openssl-2b2c78d4f0a73498739cfc0879299d7325c35160.zip openssl-2b2c78d4f0a73498739cfc0879299d7325c35160.tar.gz openssl-2b2c78d4f0a73498739cfc0879299d7325c35160.tar.bz2 |
Swap to using proper windows pipes
We were using _pipe to create a pipe on windows. This uses the "int" type
for its file descriptor for compatibility. However most windows functions
expect to use a "HANDLE". Probably we could get away with just casting but
it seems more robust to use the proper type and main stream windows
functions.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/async/arch')
-rw-r--r-- | crypto/async/arch/async_null.c | 6 | ||||
-rw-r--r-- | crypto/async/arch/async_posix.c | 6 | ||||
-rw-r--r-- | crypto/async/arch/async_win.c | 20 |
3 files changed, 18 insertions, 14 deletions
diff --git a/crypto/async/arch/async_null.c b/crypto/async/arch/async_null.c index 05b4964..f015c90 100644 --- a/crypto/async/arch/async_null.c +++ b/crypto/async/arch/async_null.c @@ -91,17 +91,17 @@ int async_pool_can_grow(void) { return 0; } -int async_pipe(int *pipefds) +int async_pipe(OSSL_ASYNC_FD *pipefds) { return -1; } -int async_write1(int fd, const void *buf) +int async_write1(OSSL_ASYNC_FD fd, const void *buf) { return -1; } -int async_read1(int fd, void *buf) +int async_read1(OSSL_ASYNC_FD fd, void *buf) { return -1; } diff --git a/crypto/async/arch/async_posix.c b/crypto/async/arch/async_posix.c index 78bf61c..3f6cb62 100644 --- a/crypto/async/arch/async_posix.c +++ b/crypto/async/arch/async_posix.c @@ -95,7 +95,7 @@ void async_fibre_free(async_fibre *fibre) OPENSSL_free(fibre->fibre.uc_stack.ss_sp); } -int async_pipe(int *pipefds) +int async_pipe(OSSL_ASYNC_FD *pipefds) { if (pipe(pipefds) == 0) return 1; @@ -103,7 +103,7 @@ int async_pipe(int *pipefds) return 0; } -int async_write1(int fd, const void *buf) +int async_write1(OSSL_ASYNC_FD fd, const void *buf) { if (write(fd, buf, 1) > 0) return 1; @@ -111,7 +111,7 @@ int async_write1(int fd, const void *buf) return 0; } -int async_read1(int fd, void *buf) +int async_read1(OSSL_ASYNC_FD fd, void *buf) { if (read(fd, buf, 1) > 0) return 1; diff --git a/crypto/async/arch/async_win.c b/crypto/async/arch/async_win.c index fce3c48..9841a9c 100644 --- a/crypto/async/arch/async_win.c +++ b/crypto/async/arch/async_win.c @@ -87,25 +87,29 @@ VOID CALLBACK async_start_func_win(PVOID unused) async_start_func(); } -int async_pipe(int *pipefds) +int async_pipe(OSSL_ASYNC_FD *pipefds) { - if (_pipe(pipefds, 256, _O_BINARY) == 0) - return 1; + if (CreatePipe(&pipefds[0], &pipefds[1], NULL, 256) == 0) + return 0; - return 0; + return 1; } -int async_write1(int fd, const void *buf) +int async_write1(OSSL_ASYNC_FD fd, const void *buf) { - if (_write(fd, buf, 1) > 0) + DWORD numwritten = 0; + + if (WriteFile(fd, buf, 1, &numwritten, NULL) && numwritten == 1) return 1; return 0; } -int async_read1(int fd, void *buf) +int async_read1(OSSL_ASYNC_FD fd, void *buf) { - if (_read(fd, buf, 1) > 0) + DWORD numread = 0; + + if (ReadFile(fd, buf, 1, &numread, NULL) && numread == 1) return 1; return 0; |