aboutsummaryrefslogtreecommitdiff
path: root/lib/util.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-02-23 15:43:34 -0800
committerBen Pfaff <blp@nicira.com>2011-02-23 15:43:34 -0800
commitc1c8308a3971526f5126201a6d1659c9247c1f0a (patch)
tree68adab7c1d6b6cd275ff3236d1029c443aa47910 /lib/util.h
parent1883ed0f727bd10f0b8b6b80832029c349138595 (diff)
util: Make out_of_memory() call abort() instead of exit(EXIT_FAILURE).
exit(EXIT_FAILURE) will make a monitoring process (the one created by --monitor) think that it should exit. But the most likely reason for out_of_memory() to be called is a bug: probably, the process is trying to allocate more memory than there is available address space, e.g. something like malloc(-1). So it's better, in my opinion, to call abort() instead, so that the monitor process restarts the daemon and we are more likely to stay alive and, in addition, get a core dump and a useful bug report. I decided to implement a new general-purpose function for this purpose in case we run into other similar situations in the future. (I haven't actually run into this problem in practice. This commit is just speculation about what is better behavior.)
Diffstat (limited to 'lib/util.h')
-rw-r--r--lib/util.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/util.h b/lib/util.h
index e741067a..635d3315 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -135,9 +135,13 @@ void *x2nrealloc(void *p, size_t *n, size_t s);
void ovs_strlcpy(char *dst, const char *src, size_t size);
void ovs_strzcpy(char *dst, const char *src, size_t size);
+void ovs_abort(int err_no, const char *format, ...)
+ PRINTF_FORMAT(2, 3) NO_RETURN;
void ovs_fatal(int err_no, const char *format, ...)
PRINTF_FORMAT(2, 3) NO_RETURN;
void ovs_error(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3);
+void ovs_error_valist(int err_no, const char *format, va_list)
+ PRINTF_FORMAT(2, 0);
const char *ovs_retval_to_string(int);
void ovs_hex_dump(FILE *, const void *, size_t, uintptr_t offset, bool ascii);