o Add an API to replace all fatal calls to exit() with a user-provided panic function.
o Replace all assert() calls with a variant that is aware of the user-provided logging and panic functions.
o Add a return value to event_assign so that it can fail rather than asserting when the user gives it bad input. event_set still dies on bad input.
+ o The event_base_new() and event_base_new_with_config() functions now never call exit() on failure. For backward "compatibility", event_init() still does, but more consistently.
Changes in 2.0.2-alpha:
struct event_base *
event_init(void)
{
- struct event_base *base = event_base_new();
+ struct event_base *base = event_base_new_with_config(NULL);
- if (base != NULL)
- current_base = base;
+ if (base == NULL)
+ event_errx(1, "%s: Unable to construct event_base", __func__);
+
+ current_base = base;
return (base);
}
struct event_base *
event_base_new(void)
{
- return (event_base_new_with_config(NULL));
+ struct event_base *base = NULL;
+ struct event_config *cfg = event_config_new();
+ if (cfg) {
+ base = event_base_new_with_config(cfg);
+ event_config_free(cfg);
+ }
+ return base;
}
static int
struct event_base *base;
int should_check_environment;
- if ((base = mm_calloc(1, sizeof(struct event_base))) == NULL)
- event_err(1, "%s: calloc", __func__);
+ if ((base = mm_calloc(1, sizeof(struct event_base))) == NULL) {
+ event_warn("%s: calloc", __func__);
+ return NULL;
+ }
detect_monotonic();
gettime(base, &base->event_tv);
}
if (base->evbase == NULL) {
- if (cfg == NULL)
- event_errx(1, "%s: no event mechanism available",
- __func__);
- else {
- event_base_free(base);
- return NULL;
- }
+ event_warnx("%s: no event mechanism available",
+ __func__);
+ event_base_free(base);
+ return NULL;
}
if (getenv("EVENT_SHOW_METHOD"))
/* Some converted-over tests */
{ "methods", test_methods, TT_FORK, NULL, NULL },
{ "version", test_version, 0, NULL, NULL },
- { "base_features", test_base_features, TT_FORK, NULL, NULL },
+ BASIC(base_features, TT_FORK|TT_NO_LOGS),
{ "base_environ", test_base_environ, TT_FORK, NULL, NULL },
BASIC(event_base_new, TT_FORK|TT_NEED_SOCKETPAIR),