From: Nick Mathewson Date: Tue, 8 May 2012 22:04:19 +0000 (-0400) Subject: Add a bufferevent_get_priority() function X-Git-Tag: release-2.1.2-alpha~95^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd395549a3a148aa143afda27aa03907c5e5c73c;p=libevent Add a bufferevent_get_priority() function --- diff --git a/bufferevent.c b/bufferevent.c index 5906335c..f47153c9 100644 --- a/bufferevent.c +++ b/bufferevent.c @@ -397,6 +397,16 @@ bufferevent_get_base(struct bufferevent *bufev) return bufev->ev_base; } +int +bufferevent_get_priority(struct bufferevent *bufev) +{ + if (event_initialized(&bufev->ev_read)) { + return event_get_priority(&bufev->ev_read); + } else { + return event_base_get_npriorities(bufev->ev_base) / 2; + } +} + int bufferevent_write(struct bufferevent *bufev, const void *data, size_t size) { diff --git a/include/event2/bufferevent.h b/include/event2/bufferevent.h index 467b4e32..b3f9b1e2 100644 --- a/include/event2/bufferevent.h +++ b/include/event2/bufferevent.h @@ -273,6 +273,12 @@ struct event_base *bufferevent_get_base(struct bufferevent *bev); */ int bufferevent_priority_set(struct bufferevent *bufev, int pri); +/** + Return the priority of a bufferevent. + + Only supported for socket bufferevents + */ +int bufferevent_get_priority(struct bufferevent *bufev); /** Deallocate the storage associated with a bufferevent structure.