httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1430514 - in /httpd/httpd/branches/2.4.x: ./ CHANGES STATUS modules/cache/mod_cache_disk.c modules/dav/fs/lock.c modules/filters/mod_ext_filter.c modules/generators/mod_cgid.c modules/mappers/mod_rewrite.c support/rotatelogs.c
Date Tue, 08 Jan 2013 20:49:50 GMT
Author: jim
Date: Tue Jan  8 20:49:50 2013
New Revision: 1430514

URL: http://svn.apache.org/viewvc?rev=1430514&view=rev
Log:
Merge r1331110 from trunk:

Replace use of apr_file_write() with apr_file_write_full() to prevent
incomplete writes.

Add comments in some places where error handling/logging is missing.

PR: 53131.
Submitted by: Nicolas Viennot <apache viennot biz>, Stefan Fritsch

Submitted by: sf
Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c
    httpd/httpd/branches/2.4.x/modules/dav/fs/lock.c
    httpd/httpd/branches/2.4.x/modules/filters/mod_ext_filter.c
    httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c
    httpd/httpd/branches/2.4.x/modules/mappers/mod_rewrite.c
    httpd/httpd/branches/2.4.x/support/rotatelogs.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1331110

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1430514&r1=1430513&r2=1430514&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Tue Jan  8 20:49:50 2013
@@ -2,6 +2,10 @@
 
 Changes with Apache 2.4.4
 
+  *) various modules, rotatelogs: Replace use of apr_file_write() with
+     apr_file_write_full() to prevent incomplete writes. PR 53131.
+     [Nicolas Viennot <apache viennot biz>, Stefan Fritsch]
+
   *) ab: Support socket timeout (-s timeout).
      [Guido Serra <zeph fsfe org>]
   

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1430514&r1=1430513&r2=1430514&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Tue Jan  8 20:49:50 2013
@@ -91,18 +91,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * Replace use of apr_file_write() with apr_file_write_full() to prevent
-     incomplete writes.
-     Add comments in some places where error handling/logging is missing.
-     PR: 53131.
-     Submitted by: Nicolas Viennot <apache viennot biz>, Stefan Fritsch
-     Not critical for 2.4.4.
-     trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1331110
-     2.4.x patch: Trunk patch works except for modules/slotmem/mod_slotmem_shm.c
-                  which should be ommitted (already done in r1400951).
-     +1: rjung, jim
-     -1: jorton on mod_log_*.c parts per <20130108093848.GA7521@redhat.com>
-     +1: jorton on non-mod_log_*.c parts
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:

Modified: httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c?rev=1430514&r1=1430513&r2=1430514&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c (original)
+++ httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c Tue Jan  8 20:49:50 2013
@@ -757,8 +757,7 @@ static apr_status_t store_array(apr_file
         iov[1].iov_base = CRLF;
         iov[1].iov_len = sizeof(CRLF) - 1;
 
-        rv = apr_file_writev(fd, (const struct iovec *) &iov, 2,
-                             &amt);
+        rv = apr_file_writev_full(fd, (const struct iovec *) &iov, 2, &amt);
         if (rv != APR_SUCCESS) {
             return rv;
         }
@@ -767,8 +766,7 @@ static apr_status_t store_array(apr_file
     iov[0].iov_base = CRLF;
     iov[0].iov_len = sizeof(CRLF) - 1;
 
-    return apr_file_writev(fd, (const struct iovec *) &iov, 1,
-                         &amt);
+    return apr_file_writev_full(fd, (const struct iovec *) &iov, 1, &amt);
 }
 
 static apr_status_t read_table(cache_handle_t *handle, request_rec *r,
@@ -916,8 +914,7 @@ static apr_status_t store_table(apr_file
             iov[3].iov_base = CRLF;
             iov[3].iov_len = sizeof(CRLF) - 1;
 
-            rv = apr_file_writev(fd, (const struct iovec *) &iov, 4,
-                                 &amt);
+            rv = apr_file_writev_full(fd, (const struct iovec *) &iov, 4, &amt);
             if (rv != APR_SUCCESS) {
                 return rv;
             }
@@ -925,8 +922,7 @@ static apr_status_t store_table(apr_file
     }
     iov[0].iov_base = CRLF;
     iov[0].iov_len = sizeof(CRLF) - 1;
-    rv = apr_file_writev(fd, (const struct iovec *) &iov, 1,
-                         &amt);
+    rv = apr_file_writev_full(fd, (const struct iovec *) &iov, 1, &amt);
     return rv;
 }
 
@@ -992,7 +988,7 @@ static apr_status_t write_headers(cache_
             }
 
             amt = sizeof(format);
-            rv = apr_file_write(dobj->vary.tempfd, &format, &amt);
+            rv = apr_file_write_full(dobj->vary.tempfd, &format, amt, NULL);
             if (rv != APR_SUCCESS) {
                 ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, APLOGNO(00722)
                         "could not write to vary file %s",
@@ -1003,8 +999,8 @@ static apr_status_t write_headers(cache_
             }
 
             amt = sizeof(h->cache_obj->info.expire);
-            rv = apr_file_write(dobj->vary.tempfd, &h->cache_obj->info.expire,
-                    &amt);
+            rv = apr_file_write_full(dobj->vary.tempfd,
+                                     &h->cache_obj->info.expire, amt, NULL);
             if (rv != APR_SUCCESS) {
                 ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, APLOGNO(00723)
                         "could not write to vary file %s",
@@ -1069,7 +1065,8 @@ static apr_status_t write_headers(cache_
     iov[1].iov_base = (void*)dobj->name;
     iov[1].iov_len = disk_info.name_len;
 
-    rv = apr_file_writev(dobj->hdrs.tempfd, (const struct iovec *) &iov, 2, &amt);
+    rv = apr_file_writev_full(dobj->hdrs.tempfd, (const struct iovec *) &iov,
+                              2, &amt);
     if (rv != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, APLOGNO(00726)
                 "could not write info to header file %s",

Modified: httpd/httpd/branches/2.4.x/modules/dav/fs/lock.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/dav/fs/lock.c?rev=1430514&r1=1430513&r2=1430514&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/dav/fs/lock.c (original)
+++ httpd/httpd/branches/2.4.x/modules/dav/fs/lock.c Tue Jan  8 20:49:50 2013
@@ -845,7 +845,7 @@ static dav_error * dav_fs_save_locknull_
     }
 
     amt = pbuf->cur_len;
-    if ((rv = apr_file_write(file, pbuf->buf, &amt)) != APR_SUCCESS
+    if ((rv = apr_file_write_full(file, pbuf->buf, amt, &amt)) != APR_SUCCESS
         || amt != pbuf->cur_len) {
         err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0, rv,
                             apr_psprintf(p,

Modified: httpd/httpd/branches/2.4.x/modules/filters/mod_ext_filter.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/filters/mod_ext_filter.c?rev=1430514&r1=1430513&r2=1430514&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/filters/mod_ext_filter.c (original)
+++ httpd/httpd/branches/2.4.x/modules/filters/mod_ext_filter.c Tue Jan  8 20:49:50 2013
@@ -681,9 +681,9 @@ static apr_status_t pass_data_to_filter(
 
     do {
         tmplen = len - bytes_written;
-        rv = apr_file_write(ctx->proc->in,
+        rv = apr_file_write_full(ctx->proc->in,
                        (const char *)data + bytes_written,
-                       &tmplen);
+                       tmplen, &tmplen);
         bytes_written += tmplen;
         if (rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv)) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, APLOGNO(01461)

Modified: httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c?rev=1430514&r1=1430513&r2=1430514&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c Tue Jan  8 20:49:50 2013
@@ -1155,7 +1155,7 @@ static int log_script(request_rec *r, cg
             apr_file_puts("%stdout\n", f);
             first = 0;
         }
-        apr_file_write(f, buf, &len);
+        apr_file_write_full(f, buf, len, NULL);
         apr_file_puts("\n", f);
     }
 

Modified: httpd/httpd/branches/2.4.x/modules/mappers/mod_rewrite.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/mappers/mod_rewrite.c?rev=1430514&r1=1430513&r2=1430514&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/mappers/mod_rewrite.c (original)
+++ httpd/httpd/branches/2.4.x/modules/mappers/mod_rewrite.c Tue Jan  8 20:49:50 2013
@@ -1403,9 +1403,10 @@ static char *lookup_map_program(request_
     /* write out the request key */
 #ifdef NO_WRITEV
     nbytes = strlen(key);
-    apr_file_write(fpin, key, &nbytes);
+    /* XXX: error handling */
+    apr_file_write_full(fpin, key, nbytes, NULL);
     nbytes = 1;
-    apr_file_write(fpin, "\n", &nbytes);
+    apr_file_write_full(fpin, "\n", nbytes, NULL);
 #else
     iova[0].iov_base = key;
     iova[0].iov_len = strlen(key);
@@ -1413,7 +1414,8 @@ static char *lookup_map_program(request_
     iova[1].iov_len = 1;
 
     niov = 2;
-    apr_file_writev(fpin, iova, niov, &nbytes);
+    /* XXX: error handling */
+    apr_file_writev_full(fpin, iova, niov, &nbytes);
 #endif
 
     buf = apr_palloc(r->pool, REWRITE_PRG_MAP_BUF + 1);

Modified: httpd/httpd/branches/2.4.x/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/support/rotatelogs.c?rev=1430514&r1=1430513&r2=1430514&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/support/rotatelogs.c (original)
+++ httpd/httpd/branches/2.4.x/support/rotatelogs.c Tue Jan  8 20:49:50 2013
@@ -459,7 +459,7 @@ static void doRotate(rotate_config_t *co
             fprintf(stderr, "Error truncating the file %s\n", status->current.name);
             exit(2);
         }
-        if (apr_file_write(status->current.fd, status->errbuf, &nWrite) != APR_SUCCESS)
{
+        if (apr_file_write_full(status->current.fd, status->errbuf, nWrite, NULL) !=
APR_SUCCESS) {
             fprintf(stderr, "Error writing to the file %s\n", status->current.name);
             exit(2);
         }
@@ -687,18 +687,7 @@ int main (int argc, const char * const a
         }
 
         nWrite = nRead;
-        rv = apr_file_write(status.current.fd, buf, &nWrite);
-        if (rv == APR_SUCCESS && nWrite != nRead) {
-            /* buffer partially written, which for rotatelogs means we encountered
-             * an error such as out of space or quota or some other limit reached;
-             * try to write the rest so we get the real error code
-             */
-            apr_size_t nWritten = nWrite;
-
-            nRead  = nRead - nWritten;
-            nWrite = nRead;
-            rv = apr_file_write(status.current.fd, buf + nWritten, &nWrite);
-        }
+        rv = apr_file_write_full(status.current.fd, buf, nWrite, &nWrite);
         if (nWrite != nRead) {
             char strerrbuf[120];
             apr_off_t cur_offset;
@@ -715,7 +704,7 @@ int main (int argc, const char * const a
                          rv, cur_offset, status.nMessCount, strerrbuf);
             nWrite = strlen(status.errbuf);
             apr_file_trunc(status.current.fd, 0);
-            if (apr_file_write(status.current.fd, status.errbuf, &nWrite) != APR_SUCCESS)
{
+            if (apr_file_write_full(status.current.fd, status.errbuf, nWrite, NULL) != APR_SUCCESS)
{
                 fprintf(stderr, "Error writing to the file %s\n", status.current.name);
                 exit(2);
             }



Mime
View raw message