- Fix overlapped I/O error handling for pipe transport
- ROS now works with Windows npfs.sys again (CORE-2198)
- Wine has this completely reworked, so this ros-diff should finally disappear with the next sync

svn path=/trunk/; revision=57365
This commit is contained in:
Thomas Faber 2012-09-22 12:47:03 +00:00
parent 3cce9acbab
commit ff9902d224
2 changed files with 21 additions and 25 deletions

View file

@ -438,10 +438,11 @@ static int rpcrt4_conn_np_read(RpcConnection *Connection,
{ {
DWORD bytes_read; DWORD bytes_read;
ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, &ovl); ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, &ovl);
if ((!ret || !bytes_read) && (GetLastError() != ERROR_IO_PENDING)) if (!ret && GetLastError() == ERROR_IO_PENDING)
break; ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_read, TRUE);
ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_read, TRUE); if (!ret && GetLastError() == ERROR_MORE_DATA)
if (!ret && (GetLastError() != ERROR_MORE_DATA)) ret = TRUE;
if (!ret || !bytes_read)
break; break;
bytes_left -= bytes_read; bytes_left -= bytes_read;
buf += bytes_read; buf += bytes_read;
@ -458,7 +459,7 @@ static int rpcrt4_conn_np_write(RpcConnection *Connection,
BOOL ret = TRUE; BOOL ret = TRUE;
unsigned int bytes_left = count; unsigned int bytes_left = count;
OVERLAPPED ovl; OVERLAPPED ovl;
ZeroMemory(&ovl, sizeof(ovl)); ZeroMemory(&ovl, sizeof(ovl));
ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
@ -466,10 +467,9 @@ static int rpcrt4_conn_np_write(RpcConnection *Connection,
{ {
DWORD bytes_written; DWORD bytes_written;
ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, &ovl); ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, &ovl);
if ((!ret || !bytes_written) && (GetLastError() != ERROR_IO_PENDING)) if (!ret && GetLastError() == ERROR_IO_PENDING)
break; ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_written, TRUE);
ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_written, TRUE); if (!ret || !bytes_written)
if (!ret && (GetLastError() != ERROR_MORE_DATA))
break; break;
bytes_left -= bytes_written; bytes_left -= bytes_written;
buf += bytes_written; buf += bytes_written;

View file

@ -127,7 +127,7 @@ Index: rpc_transport.c
I_RpcFree(pname); I_RpcFree(pname);
return r; return r;
@@ -412,18 +429,24 @@ static int rpcrt4_conn_np_read(RpcConnec @@ -412,11 +429,17 @@ static int rpcrt4_conn_np_read(RpcConnec
char *buf = buffer; char *buf = buffer;
BOOL ret = TRUE; BOOL ret = TRUE;
unsigned int bytes_left = count; unsigned int bytes_left = count;
@ -140,15 +140,13 @@ Index: rpc_transport.c
{ {
DWORD bytes_read; DWORD bytes_read;
- ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, NULL); - ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, NULL);
- if (!ret && GetLastError() == ERROR_MORE_DATA)
- ret = TRUE;
- if (!ret || !bytes_read)
+ ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, &ovl); + ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, &ovl);
+ if ((!ret || !bytes_read) && (GetLastError() != ERROR_IO_PENDING)) + if (!ret && GetLastError() == ERROR_IO_PENDING)
+ break; + ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_read, TRUE);
+ ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_read, TRUE); if (!ret && GetLastError() == ERROR_MORE_DATA)
+ if (!ret && (GetLastError() != ERROR_MORE_DATA)) ret = TRUE;
break; if (!ret || !bytes_read)
@@ -424,6 +447,7 @@ static int rpcrt4_conn_np_read(RpcConnec
bytes_left -= bytes_read; bytes_left -= bytes_read;
buf += bytes_read; buf += bytes_read;
} }
@ -156,12 +154,12 @@ Index: rpc_transport.c
return ret ? count : -1; return ret ? count : -1;
} }
@@ -434,16 +457,24 @@ static int rpcrt4_conn_np_write(RpcConne @@ -434,16 +458,23 @@ static int rpcrt4_conn_np_write(RpcConne
const char *buf = buffer; const char *buf = buffer;
BOOL ret = TRUE; BOOL ret = TRUE;
unsigned int bytes_left = count; unsigned int bytes_left = count;
+ OVERLAPPED ovl; + OVERLAPPED ovl;
+ +
+ ZeroMemory(&ovl, sizeof(ovl)); + ZeroMemory(&ovl, sizeof(ovl));
+ ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); + ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
@ -169,12 +167,10 @@ Index: rpc_transport.c
{ {
DWORD bytes_written; DWORD bytes_written;
- ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, NULL); - ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, NULL);
- if (!ret || !bytes_written)
+ ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, &ovl); + ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, &ovl);
+ if ((!ret || !bytes_written) && (GetLastError() != ERROR_IO_PENDING)) + if (!ret && GetLastError() == ERROR_IO_PENDING)
+ break; + ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_written, TRUE);
+ ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_written, TRUE); if (!ret || !bytes_written)
+ if (!ret && (GetLastError() != ERROR_MORE_DATA))
break; break;
bytes_left -= bytes_written; bytes_left -= bytes_written;
buf += bytes_written; buf += bytes_written;