3-7 20:00
This commit is contained in:
parent
e73111f3d9
commit
682fac1587
|
@ -393,6 +393,8 @@ VOID CALLBACK WriteCompletionRoutine(
|
|||
pio->write_details.remaining);
|
||||
pio->write_details.error = dwErrorCode;
|
||||
/* TODO - assert that remaining == dwNumberOfBytesTransfered */
|
||||
if (pio->write_details.remaining != dwNumberOfBytesTransfered)
|
||||
abort();
|
||||
pio->write_details.remaining -= dwNumberOfBytesTransfered;
|
||||
pio->write_details.pending = FALSE;
|
||||
}
|
||||
|
@ -453,6 +455,7 @@ fileio_write(struct w32_io* pio, const void *buf, unsigned int max) {
|
|||
if (WriteFileEx(h, pio->write_details.buf, bytes_copied,
|
||||
&pio->write_overlapped, &WriteCompletionRoutine)) {
|
||||
pio->write_details.pending = TRUE;
|
||||
pio->write_details.remaining = bytes_copied;
|
||||
/* execute APC if write has completed */
|
||||
if (wait_for_any_event(NULL, 0, 0) == -1)
|
||||
return -1;
|
||||
|
|
|
@ -622,7 +622,15 @@ w32_dup(int oldfd) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!DuplicateHandle(GetCurrentProcess(), src, GetCurrentProcess(), &target, 0, TRUE, DUPLICATE_SAME_ACCESS)) {
|
||||
if ((oldfd == STDIN_FILENO) && (GetFileType(GetStdHandle(STD_INPUT_HANDLE)) == FILE_TYPE_CHAR)) {
|
||||
target = CreateFile(L"CONIN$", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED, NULL);
|
||||
if (target == INVALID_HANDLE_VALUE) {
|
||||
errno = EOTHER;
|
||||
debug("ERROR: CreateFile CONIN$ failed, error:%d", GetLastError());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (!DuplicateHandle(GetCurrentProcess(), src, GetCurrentProcess(), &target, 0, TRUE, DUPLICATE_SAME_ACCESS)) {
|
||||
errno = EOTHER;
|
||||
debug("ERROR: Duplicated Handle failed, error:%d", GetLastError());
|
||||
return -1;
|
||||
|
@ -636,6 +644,7 @@ w32_dup(int oldfd) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
memset(pio, 0, sizeof(struct w32_io));
|
||||
pio->handle = target;
|
||||
pio->type = FILE_FD;
|
||||
fd_table_set(pio, min_index);
|
||||
|
|
|
@ -239,7 +239,7 @@ void
|
|||
file_tests()
|
||||
{
|
||||
w32posix_initialize();
|
||||
//console_io_test();
|
||||
console_io_test();
|
||||
//file_simple_fileio();
|
||||
file_blocking_io_tests();
|
||||
file_nonblocking_io_tests();
|
||||
|
|
Loading…
Reference in New Issue