mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
fix the return value of event_deferred_cb_schedule_
This commit is contained in:
parent
31c6d45f8d
commit
38cef641c4
@ -58,7 +58,7 @@ void event_deferred_cb_cancel_(struct event_base *, struct event_callback *);
|
||||
/**
|
||||
Activate a struct event_callback if it is not currently scheduled in an event_base.
|
||||
|
||||
Return true iff it was not previously scheduled.
|
||||
Return true if it was not previously scheduled.
|
||||
*/
|
||||
int event_deferred_cb_schedule_(struct event_base *, struct event_callback *);
|
||||
|
||||
|
@ -435,7 +435,7 @@ int event_callback_finalize_many_(struct event_base *base, int n_cbs, struct eve
|
||||
|
||||
void event_active_later_(struct event *ev, int res);
|
||||
void event_active_later_nolock_(struct event *ev, int res);
|
||||
void event_callback_activate_later_nolock_(struct event_base *base,
|
||||
int event_callback_activate_later_nolock_(struct event_base *base,
|
||||
struct event_callback *evcb);
|
||||
int event_callback_cancel_nolock_(struct event_base *base,
|
||||
struct event_callback *evcb, int even_if_finalizing);
|
||||
|
11
event.c
11
event.c
@ -2931,16 +2931,17 @@ event_callback_activate_nolock_(struct event_base *base,
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
event_callback_activate_later_nolock_(struct event_base *base,
|
||||
struct event_callback *evcb)
|
||||
{
|
||||
if (evcb->evcb_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER))
|
||||
return;
|
||||
return 0;
|
||||
|
||||
event_queue_insert_active_later(base, evcb);
|
||||
if (EVBASE_NEED_NOTIFY(base))
|
||||
evthread_notify_base(base);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
@ -3025,10 +3026,12 @@ event_deferred_cb_schedule_(struct event_base *base, struct event_callback *cb)
|
||||
base = current_base;
|
||||
EVBASE_ACQUIRE_LOCK(base, th_base_lock);
|
||||
if (base->n_deferreds_queued > MAX_DEFERREDS_QUEUED) {
|
||||
event_callback_activate_later_nolock_(base, cb);
|
||||
r = event_callback_activate_later_nolock_(base, cb);
|
||||
} else {
|
||||
++base->n_deferreds_queued;
|
||||
r = event_callback_activate_nolock_(base, cb);
|
||||
if (r) {
|
||||
++base->n_deferreds_queued;
|
||||
}
|
||||
}
|
||||
EVBASE_RELEASE_LOCK(base, th_base_lock);
|
||||
return r;
|
||||
|
Loading…
x
Reference in New Issue
Block a user