summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2011-10-08 09:54:31 +0200
committerStefan Fritsch <sf@apache.org>2011-10-08 09:54:31 +0200
commitcaf0908cf536eff9aef420c570d7a6e737b97d09 (patch)
treefa5d51413164e531d0806131aede4b85c9a0b174
parentFix format string bugs in mod_lua. Found by gcc and pointed out by Igor Galic. (diff)
downloadapache2-caf0908cf536eff9aef420c570d7a6e737b97d09.tar.xz
apache2-caf0908cf536eff9aef420c570d7a6e737b97d09.zip
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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1180334 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--server/util.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/server/util.c b/server/util.c
index e58ad76aeb..2444a0d667 100644
--- a/server/util.c
+++ b/server/util.c
@@ -2651,12 +2651,22 @@ AP_DECLARE(void) ap_varbuf_regsub(struct ap_varbuf *vb, const char *input,
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();
}