You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2002/08/06 08:50:18 UTC
cvs commit: apr/network_io/win32 sendrecv.c
wrowe 2002/08/05 23:50:18
Modified: network_io/win32 sendrecv.c
Log:
Solve the elusive .pdf failure on Win32.
Where Headers + Trailers were present, we always blasted the Headers.
Now, we reinitialize the hdtr structure after consuming it, instead of
trying to initialize for both headers and trailers.
[RM - can we update the .40 test tag for this patch?]
PR: 10781
Revision Changes Path
1.57 +17 -14 apr/network_io/win32/sendrecv.c
Index: sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sendrecv.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- sendrecv.c 15 Jul 2002 07:26:12 -0000 1.56
+++ sendrecv.c 6 Aug 2002 06:50:17 -0000 1.57
@@ -280,14 +280,6 @@
return APR_ENOTIMPL;
}
- /* Initialize the overlapped structure */
- memset(&overlapped,'\0', sizeof(overlapped));
-#ifdef WAIT_FOR_EVENT
- wait_event = overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
-#else
- wait_event = (HANDLE) sock->socketdes;
-#endif
-
/* Use len to keep track of number of total bytes sent (including headers) */
bytes_to_send = *len;
*len = 0;
@@ -309,9 +301,17 @@
return APR_SUCCESS;
}
+ /* Initialize the header/trailer and overlapped structures */
+ memset(&tfb, '\0', sizeof (tfb));
+ memset(&overlapped,'\0', sizeof(overlapped));
+#ifdef WAIT_FOR_EVENT
+ wait_event = overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+#else
+ wait_event = (HANDLE) sock->socketdes;
+#endif
+
/* Collapse the headers into a single buffer */
if (hdtr && hdtr->numheaders) {
- memset(&tfb, '\0', sizeof (tfb));
ptfb = &tfb;
collapse_iovec((char **)&ptfb->Head, &ptfb->HeadLength, hdtr->headers,
hdtr->numheaders, sock->cntxt);
@@ -326,7 +326,6 @@
nbytes = bytes_to_send;
/* Collapse the trailers into a single buffer */
if (hdtr && hdtr->numtrailers) {
- memset(&tfb, '\0', sizeof (tfb));
ptfb = &tfb;
collapse_iovec((char**) &ptfb->Tail, &ptfb->TailLength,
hdtr->trailers, hdtr->numtrailers, sock->cntxt);
@@ -342,7 +341,8 @@
overlapped.Offset = (DWORD)(curoff);
#if APR_HAS_LARGE_FILES
overlapped.OffsetHigh = (DWORD)(curoff >> 32);
-#endif
+#endif
+ /* XXX BoundsChecker claims dwFlags must not be zero. */
rv = TransmitFile(sock->socketdes, /* socket */
file->filehand, /* open file descriptor of the file to be sent */
nbytes, /* number of bytes to send. 0=send all */
@@ -353,7 +353,8 @@
if (!rv) {
status = apr_get_netos_error();
if ((status == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) ||
- (status == APR_FROM_OS_ERROR(WSA_IO_PENDING))) {
+ (status == APR_FROM_OS_ERROR(WSA_IO_PENDING)))
+ {
rv = WaitForSingleObject(wait_event,
(DWORD)(sock->timeout >= 0
? sock->timeout_ms : INFINITE));
@@ -362,7 +363,7 @@
if (!disconnected) {
if (!GetOverlappedResult(wait_event, &overlapped,
&nbytes, FALSE)) {
- status = APR_FROM_OS_ERROR(GetLastError());
+ status = apr_get_os_error();
}
/* Ugly code alert: GetOverlappedResult returns
* a count of all bytes sent. This loop only
@@ -373,8 +374,9 @@
}
}
}
- else if (rv == WAIT_TIMEOUT)
+ else if (rv == WAIT_TIMEOUT) {
status = APR_FROM_OS_ERROR(WAIT_TIMEOUT);
+ }
else if (rv == WAIT_ABANDONED) {
/* Hummm... WAIT_ABANDONDED is not an error code. It is
* a return specific to the Win32 WAIT functions that
@@ -397,6 +399,7 @@
/* Adjust len for any headers/trailers sent */
if (ptfb) {
*len += (ptfb->HeadLength + ptfb->TailLength);
+ memset(&tfb, '\0', sizeof (tfb));
ptfb = NULL;
}
}