httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Victor J. Orlikowski" <...@raleigh.ibm.com>
Subject [PATCH] Fixes to AIX ap_sendfile
Date Fri, 23 Jun 2000 15:03:11 GMT
Following advice from my betters, here are fixes to my ap_sendfile
implementation for AIX.

Index: src/lib/apr/network_io/unix/sendrecv.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.26
diff -u -r1.26 sendrecv.c
--- sendrecv.c 2000/06/22 19:33:18 1.26
+++ sendrecv.c 2000/06/23 14:34:30
@@ -459,11 +459,11 @@
                         ap_int32_t flags)
 {
     int i, ptr, rv = 0;
-    void * hbuf=NULL, * tbuf=NULL;
+    void * hbuf=NULL, * tbuf=NULL;
     ap_status_t arv;
     struct sf_parms parms;

-    /* AIX can also send the headers/footers as part of the system call
+    /* AIX can also send the headers/footers as part of the system call
        ... badly.*/
     parms.header_length = 0;
     if (hdtr && hdtr->numheaders) {
@@ -472,12 +472,12 @@
             parms.header_length = hdtr->headers[0].iov_len;
         }
         else {
-            for (i = 0; i < hdtr->numheaders; i++) {
+            for (i = 0; i < hdtr->numheaders; i++)

                 parms.header_length += hdtr->headers[i].iov_len;
             }
-            /* Keepalives make ap_palloc a bad idea */
-            hbuf = malloc(parms.header_length);
-            ptr = 0;
+            /* XXX:  BUHHH? wow, what a memory leak! */
+            hbuf = ap_palloc(sock->cntxt, parms.header_length);
+     ptr = 0;
             for (i = 0; i < hdtr->numheaders; i++) {
                 memcpy(hbuf + ptr, hdtr->headers[i].iov_base,
                        hdtr->headers[i].iov_len);
@@ -497,8 +497,8 @@
             for (i = 0; i < hdtr->numtrailers; i++) {
                 parms.trailer_length += hdtr->trailers[i].iov_len;
             }
-            /* Keepalives make ap_palloc a bad idea */
-            tbuf = malloc(parms.trailer_length);
+            /* XXX:  BUHHH? wow, what a memory leak! */
+            tbuf = ap_palloc(sock->cntxt, parms.trailer_length);
             ptr = 0;
             for (i = 0; i < hdtr->numtrailers; i++) {
                 memcpy(tbuf + ptr, hdtr->trailers[i].iov_base,
@@ -512,17 +512,17 @@

     /* Whew! Headers and trailers set up. Now for the file data */

-    parms.file_descriptor = file->filedes;
+    parms.file_descriptor = file->filedes;
     parms.file_offset = *offset;
     parms.file_bytes = *len;

     /* O.K. All set up now. Let's go to town */
-
+
     do {
         rv = send_file(&(sock->socketdes), /* socket */
                        &(parms),           /* all data */
                        flags               /* flags */
-            );
+                      );
     } while (rv == -1 && errno == EINTR);

     if (rv == -1 &&
@@ -538,21 +538,18 @@
                 rv = send_file(&(sock->socketdes), /* socket */
                                &(parms),           /* all data */
                                flags               /* flags */
-                    );
+                              );
             } while (rv == -1 && errno == EINTR);
         }
     }

     (*len) = parms.bytes_sent;

-    /* Clean up after ourselves */
-    if(hbuf) free(hbuf);
-    if(tbuf) free(tbuf);
-
     if (rv == -1) {
         return errno;
     }
-    return APR_SUCCESS;
+    return APR_SUCCESS;
 }
+#else
 #endif /* __linux__, __FreeBSD__, __HPUX__, _AIX */
 #endif /* APR_HAS_SENDFILE */



Mime
View raw message