]> granicus.if.org Git - libevent/commitdiff
Add a bufferevent_get_priority() function
authorNick Mathewson <nickm@torproject.org>
Tue, 8 May 2012 22:04:19 +0000 (18:04 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 9 May 2012 16:06:00 +0000 (12:06 -0400)
bufferevent.c
include/event2/bufferevent.h

index 5906335c08a9b199d59d7ac25f5b12df04769764..f47153c99dac83b5afc072c3b8c0d1e118ea8b7a 100644 (file)
@@ -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)
 {
index 467b4e323b280a3bce7b2db05cfe5c7139c6ad32..b3f9b1e2d577baa60fcccbe58d504620c5d6b6ec 100644 (file)
@@ -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.