httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1180334 - /httpd/httpd/trunk/server/util.c
Date Sat, 08 Oct 2011 07:54:31 GMT
Author: sf
Date: Sat Oct  8 07:54:31 2011
New Revision: 1180334

URL: http://svn.apache.org/viewvc?rev=1180334&view=rev
Log:
Shut up gcc/glibc warning about ignoring write()'s return value.

This may actually fix a real bug in case the error log is directed to a FIFO.

Modified:
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1180334&r1=1180333&r2=1180334&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Sat Oct  8 07:54:31 2011
@@ -2651,12 +2651,22 @@ AP_DECLARE(void) ap_varbuf_regsub(struct
     regsub_core(NULL, vb, input, source, nmatch, pmatch);
 }
 
-#define OOM_MESSAGE "[crit] Memory allocation failed, " \
-        "aborting process." APR_EOL_STR
+static const char * const oom_message = "[crit] Memory allocation failed, "
+                                        "aborting process." APR_EOL_STR;
 
 AP_DECLARE(void) ap_abort_on_oom()
 {
-    write(STDERR_FILENO, OOM_MESSAGE, strlen(OOM_MESSAGE));
+    int written, count = strlen(oom_message);
+    const char *buf = oom_message;
+    do {
+        written = write(STDERR_FILENO, buf, count);
+        if (written == count)
+            break;
+        if (written > 0) {
+            buf += written;
+            count -= written;
+        }
+    } while (written >= 0 || errno == EINTR);
     abort();
 }
 



Mime
View raw message