1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Add command line option -no-libevent

This commit is contained in:
Witold Filipczyk 2017-11-16 18:23:47 +01:00
parent 4c4717b82a
commit f52e3187e3
3 changed files with 49 additions and 40 deletions

View File

@ -869,6 +869,10 @@ union option_info cmdline_options_info[] = {
"configuration values to be used and disables saving of "
"runtime state files.")),
INIT_OPT_BOOL("", N_("Disable libevent"),
"no-libevent", 0, 0,
N_("Disables libevent.")),
INIT_OPT_CMDALIAS("", N_("Disable link numbering in dump output"),
"no-numbering", OPT_ALIAS_NEGATE, "document.dump.numbering",
N_("Prevents printing of link number in dump output.\n"

View File

@ -263,7 +263,7 @@ enable_libevent(void)
{
int i;
if (0 /* disable_libevent */)
if (get_cmd_opt_bool("no-libevent"))
return;
#if !defined(NO_FORK_ON_EXIT) && defined(HAVE_KQUEUE) && !defined(HAVE_EVENT_REINIT)

View File

@ -46,40 +46,6 @@ get_timers_count(void)
}
void
check_timers(timeval_T *last_time)
{
timeval_T now;
timeval_T interval;
struct timer *timer;
timeval_now(&now);
timeval_sub(&interval, last_time, &now);
foreach (timer, timers) {
timeval_sub_interval(&timer->interval, &interval);
}
while (!list_empty(timers)) {
timer = timers.next;
if (timeval_is_positive(&timer->interval))
break;
del_from_list(timer);
/* At this point, *@timer is to be considered invalid
* outside timers.c; if anything e.g. passes it to
* @kill_timer, that's a bug. However, @timer->func
* and @check_bottom_halves can still call @kill_timer
* on other timers, so this loop must be careful not to
* keep pointers to them. (bug 868) */
timer->func(timer->data);
mem_free(timer);
check_bottom_halves();
}
timeval_copy(last_time, &now);
}
#ifdef HAVE_EVENT_BASE_SET
extern struct event_base *event_base;
@ -110,6 +76,46 @@ struct event *timer_event(struct timer *tm)
}
#endif
void
check_timers(timeval_T *last_time)
{
timeval_T now;
timeval_T interval;
struct timer *timer;
timeval_now(&now);
timeval_sub(&interval, last_time, &now);
foreach (timer, timers) {
timeval_sub_interval(&timer->interval, &interval);
}
while (!list_empty(timers)) {
timer = timers.next;
if (timeval_is_positive(&timer->interval))
break;
del_from_list(timer);
/* At this point, *@timer is to be considered invalid
* outside timers.c; if anything e.g. passes it to
* @kill_timer, that's a bug. However, @timer->func
* and @check_bottom_halves can still call @kill_timer
* on other timers, so this loop must be careful not to
* keep pointers to them. (bug 868) */
timer->func(timer->data);
#ifdef USE_LIBEVENT
mem_free(timer_event(timer));
#else
mem_free(timer);
#endif
check_bottom_halves();
}
timeval_copy(last_time, &now);
}
static void
set_event_for_timer(timer_id_T tm)
{
@ -150,10 +156,8 @@ install_timer(timer_id_T *id, milliseconds_T delay, void (*func)(void *), void *
assert(id && delay > 0);
#ifdef USE_LIBEVENT
{
unsigned char *q = mem_alloc(sizeof_struct_event + sizeof(struct timer));
new_timer = (struct timer *)(q + sizeof_struct_event);
}
unsigned char *q = mem_alloc(sizeof_struct_event + sizeof(struct timer));
new_timer = (struct timer *)(q + sizeof_struct_event);
#else
new_timer = mem_alloc(sizeof(*new_timer));
#endif
@ -190,8 +194,9 @@ kill_timer(timer_id_T *id)
del_from_list(timer);
#ifdef USE_LIBEVENT
if (event_enabled)
if (event_enabled) {
timeout_del(timer_event(timer));
}
mem_free(timer_event(timer));
#else
mem_free(timer);