}\r
\r
/* transmit packet header */\r
- if (!WriteFile(Connection->conn, Header, hdr_size, &count, NULL)) {\r
+ ResetEvent(Connection->ovl.hEvent);\r
+ if (!WriteFile(Connection->conn, Header, hdr_size, &count, &Connection->ovl)) {\r
WARN("WriteFile failed with error %ld\n", GetLastError());\r
return GetLastError();\r
}\r
+ if (!GetOverlappedResult(Connection->conn, &Connection->ovl, &count, TRUE)) {\r
+ WARN("GetOverlappedResult failed with error %ld\n", GetLastError());\r
+ return GetLastError();\r
+ }\r
\r
/* fragment consisted of header only and is the last one */\r
if (hdr_size == Header->common.frag_len &&\r
}\r
\r
/* send the fragment data */\r
- if (!WriteFile(Connection->conn, buffer_pos, Header->common.frag_len - hdr_size, &count, NULL)) {\r
+ ResetEvent(Connection->ovl.hEvent);\r
+ if (!WriteFile(Connection->conn, buffer_pos, Header->common.frag_len - hdr_size, &count, &Connection->ovl)) {\r
WARN("WriteFile failed with error %ld\n", GetLastError());\r
return GetLastError();\r
}\r
+ if (!GetOverlappedResult(Connection->conn, &Connection->ovl, &count, TRUE)) {\r
+ WARN("GetOverlappedResult failed with error %ld\n", GetLastError());\r
+ return GetLastError();\r
+ }\r
\r
Header->common.flags &= ~RPC_FLG_FIRST;\r
}\r
TRACE("(%p, %p, %p)\n", Connection, Header, pMsg);\r
\r
/* read packet common header */\r
- if (!ReadFile(Connection->conn, &common_hdr, sizeof(common_hdr), &dwRead, NULL)) {\r
+ ResetEvent(Connection->ovl.hEvent);\r
+ if (!ReadFile(Connection->conn, &common_hdr, sizeof(common_hdr), &dwRead, &Connection->ovl)) {\r
+ WARN("ReadFile failed with error %ld\n", GetLastError());\r
+ status = RPC_S_PROTOCOL_ERROR;\r
+ goto fail;\r
+ }\r
+ if (!GetOverlappedResult(Connection->conn, &Connection->ovl, &dwRead, TRUE)) {\r
if (GetLastError() != ERROR_MORE_DATA) {\r
- WARN("ReadFile failed with error %ld\n", GetLastError());\r
+ WARN("GetOverlappedResult failed with error %ld\n", GetLastError());\r
status = RPC_S_PROTOCOL_ERROR;\r
goto fail;\r
}\r
memcpy(*Header, &common_hdr, sizeof(common_hdr));\r
\r
/* read the rest of packet header */\r
+ ResetEvent(Connection->ovl.hEvent);\r
if (!ReadFile(Connection->conn, &(*Header)->common + 1,\r
- hdr_length - sizeof(common_hdr), &dwRead, NULL)) {\r
+ hdr_length - sizeof(common_hdr), &dwRead, &Connection->ovl)) {\r
+ WARN("ReadFile failed with error %ld\n", GetLastError());\r
+ status = RPC_S_PROTOCOL_ERROR;\r
+ goto fail;\r
+ }\r
+ if (!GetOverlappedResult(Connection->conn, &Connection->ovl, &dwRead, TRUE)) {\r
if (GetLastError() != ERROR_MORE_DATA) {\r
- WARN("ReadFile failed with error %ld\n", GetLastError());\r
+ WARN("GetOverlappedResult failed with error %ld\n", GetLastError());\r
status = RPC_S_PROTOCOL_ERROR;\r
goto fail;\r
}\r
goto fail;\r
}\r
\r
+\r
/* read packet body */\r
switch (common_hdr.ptype) {\r
case PKT_RESPONSE:\r
goto fail;\r
}\r
\r
- if (data_length == 0) dwRead = 0; else\r
- if (!ReadFile(Connection->conn, buffer_ptr, data_length, &dwRead, NULL)) {\r
- if (GetLastError() != ERROR_MORE_DATA) {\r
+ if (data_length == 0) dwRead = 0; else {\r
+ ResetEvent(Connection->ovl.hEvent);\r
+ if (!ReadFile(Connection->conn, buffer_ptr, data_length, &dwRead, &Connection->ovl)) {\r
WARN("ReadFile failed with error %ld\n", GetLastError());\r
status = RPC_S_PROTOCOL_ERROR;\r
goto fail;\r
}\r
+ if (!GetOverlappedResult(Connection->conn, &Connection->ovl, &dwRead, TRUE)) {\r
+ if (GetLastError() != ERROR_MORE_DATA) {\r
+ WARN("GetOverlappedResult failed with error %ld\n", GetLastError());\r
+ status = RPC_S_PROTOCOL_ERROR;\r
+ goto fail;\r
+ }\r
+ }\r
}\r
if (dwRead != data_length) {\r
status = RPC_S_PROTOCOL_ERROR;\r
TRACE("next header\n");\r
\r
/* read the header of next packet */\r
- if (!ReadFile(Connection->conn, *Header, hdr_length, &dwRead, NULL)) {\r
+ ResetEvent(Connection->ovl.hEvent);\r
+ if (!ReadFile(Connection->conn, *Header, hdr_length, &dwRead, &Connection->ovl)) {\r
+ WARN("ReadFile failed with error %ld\n", GetLastError());\r
+ status = GetLastError();\r
+ goto fail;\r
+ }\r
+ if (!GetOverlappedResult(Connection->conn, &Connection->ovl, &dwRead, TRUE)) {\r
if (GetLastError() != ERROR_MORE_DATA) {\r
- WARN("ReadFile failed with error %ld\n", GetLastError());\r
- status = GetLastError();\r
+ WARN("GetOverlappedResult failed with error %ld\n", GetLastError());\r
+ status = RPC_S_PROTOCOL_ERROR;\r
goto fail;\r
}\r
}\r