mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Add a flag to disable checking the EVENT_* environment variables.
svn:r1220
This commit is contained in:
parent
1f9c9e5137
commit
11ff74cf64
8
event.c
8
event.c
@ -239,6 +239,7 @@ event_base_new_with_config(struct event_config *cfg)
|
||||
{
|
||||
int i;
|
||||
struct event_base *base;
|
||||
int should_check_environment;
|
||||
|
||||
if ((base = mm_calloc(1, sizeof(struct event_base))) == NULL)
|
||||
event_err(1, "%s: calloc", __func__);
|
||||
@ -259,6 +260,10 @@ event_base_new_with_config(struct event_config *cfg)
|
||||
evmap_signal_initmap(&base->sigmap);
|
||||
|
||||
base->evbase = NULL;
|
||||
|
||||
should_check_environment =
|
||||
cfg && (cfg->flags & EVENT_BASE_FLAG_IGNORE_ENV);
|
||||
|
||||
for (i = 0; eventops[i] && !base->evbase; i++) {
|
||||
if (cfg != NULL) {
|
||||
/* determine if this backend should be avoided */
|
||||
@ -271,7 +276,8 @@ event_base_new_with_config(struct event_config *cfg)
|
||||
}
|
||||
|
||||
/* also obey the environment variables */
|
||||
if (event_is_method_disabled(eventops[i]->name))
|
||||
if (should_check_environment &&
|
||||
event_is_method_disabled(eventops[i]->name))
|
||||
continue;
|
||||
|
||||
base->evsel = eventops[i];
|
||||
|
@ -160,7 +160,12 @@ enum event_method_feature {
|
||||
};
|
||||
|
||||
enum event_base_config_flag {
|
||||
/** Do not allocate a lock for the event base, even if we have
|
||||
locking set up. */
|
||||
EVENT_BASE_FLAG_NOLOCK = 0x01,
|
||||
/** Do not check the EVENT_NO* environment variables when picking
|
||||
an event_base. */
|
||||
EVENT_BASE_FLAG_IGNORE_ENV = 0x02,
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user