bufferevent-internal.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /*
  2. * Copyright (c) 2008-2012 Niels Provos and Nick Mathewson
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * 3. The name of the author may not be used to endorse or promote products
  13. * derived from this software without specific prior written permission.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef BUFFEREVENT_INTERNAL_H_INCLUDED_
  27. #define BUFFEREVENT_INTERNAL_H_INCLUDED_
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #include "event2/event-config.h"
  32. #include "event2/event_struct.h"
  33. #include "evconfig-private.h"
  34. #include "event2/util.h"
  35. #include "defer-internal.h"
  36. #include "evthread-internal.h"
  37. #include "event2/thread.h"
  38. #include "ratelim-internal.h"
  39. #include "event2/bufferevent_struct.h"
  40. #include "ipv6-internal.h"
  41. #ifdef _WIN32
  42. #include <ws2tcpip.h>
  43. #endif
  44. #ifdef EVENT__HAVE_NETINET_IN_H
  45. #include <netinet/in.h>
  46. #endif
  47. #ifdef EVENT__HAVE_NETINET_IN6_H
  48. #error #include <netinet/in6.h>
  49. #endif
  50. /* These flags are reasons that we might be declining to actually enable
  51. reading or writing on a bufferevent.
  52. */
  53. /* On a all bufferevents, for reading: used when we have read up to the
  54. watermark value.
  55. On a filtering bufferevent, for writing: used when the underlying
  56. bufferevent's write buffer has been filled up to its watermark
  57. value.
  58. */
  59. #define BEV_SUSPEND_WM 0x01
  60. /* On a base bufferevent: when we have emptied a bandwidth buckets */
  61. #define BEV_SUSPEND_BW 0x02
  62. /* On a base bufferevent: when we have emptied the group's bandwidth bucket. */
  63. #define BEV_SUSPEND_BW_GROUP 0x04
  64. /* On a socket bufferevent: can't do any operations while we're waiting for
  65. * name lookup to finish. */
  66. #define BEV_SUSPEND_LOOKUP 0x08
  67. /* On a base bufferevent, for reading: used when a filter has choked this
  68. * (underlying) bufferevent because it has stopped reading from it. */
  69. #define BEV_SUSPEND_FILT_READ 0x10
  70. typedef ev_uint16_t bufferevent_suspend_flags;
  71. struct bufferevent_rate_limit_group {
  72. /** List of all members in the group */
  73. LIST_HEAD(rlim_group_member_list, bufferevent_private) members;
  74. /** Current limits for the group. */
  75. struct ev_token_bucket rate_limit;
  76. struct ev_token_bucket_cfg rate_limit_cfg;
  77. /** True iff we don't want to read from any member of the group.until
  78. * the token bucket refills. */
  79. unsigned read_suspended : 1;
  80. /** True iff we don't want to write from any member of the group.until
  81. * the token bucket refills. */
  82. unsigned write_suspended : 1;
  83. /** True iff we were unable to suspend one of the bufferevents in the
  84. * group for reading the last time we tried, and we should try
  85. * again. */
  86. unsigned pending_unsuspend_read : 1;
  87. /** True iff we were unable to suspend one of the bufferevents in the
  88. * group for writing the last time we tried, and we should try
  89. * again. */
  90. unsigned pending_unsuspend_write : 1;
  91. /*@{*/
  92. /** Total number of bytes read or written in this group since last
  93. * reset. */
  94. ev_uint64_t total_read;
  95. ev_uint64_t total_written;
  96. /*@}*/
  97. /** The number of bufferevents in the group. */
  98. int n_members;
  99. /** The smallest number of bytes that any member of the group should
  100. * be limited to read or write at a time. */
  101. ev_ssize_t min_share;
  102. ev_ssize_t configured_min_share;
  103. /** Timeout event that goes off once a tick, when the bucket is ready
  104. * to refill. */
  105. struct event master_refill_event;
  106. /** Seed for weak random number generator. Protected by 'lock' */
  107. struct evutil_weakrand_state weakrand_seed;
  108. /** Lock to protect the members of this group. This lock should nest
  109. * within every bufferevent lock: if you are holding this lock, do
  110. * not assume you can lock another bufferevent. */
  111. void *lock;
  112. };
  113. /** Fields for rate-limiting a single bufferevent. */
  114. struct bufferevent_rate_limit {
  115. /* Linked-list elements for storing this bufferevent_private in a
  116. * group.
  117. *
  118. * Note that this field is supposed to be protected by the group
  119. * lock */
  120. LIST_ENTRY(bufferevent_private) next_in_group;
  121. /** The rate-limiting group for this bufferevent, or NULL if it is
  122. * only rate-limited on its own. */
  123. struct bufferevent_rate_limit_group *group;
  124. /* This bufferevent's current limits. */
  125. struct ev_token_bucket limit;
  126. /* Pointer to the rate-limit configuration for this bufferevent.
  127. * Can be shared. XXX reference-count this? */
  128. struct ev_token_bucket_cfg *cfg;
  129. /* Timeout event used when one this bufferevent's buckets are
  130. * empty. */
  131. struct event refill_bucket_event;
  132. };
  133. /** Parts of the bufferevent structure that are shared among all bufferevent
  134. * types, but not exposed in bufferevent_struct.h. */
  135. struct bufferevent_private {
  136. /** The underlying bufferevent structure. */
  137. struct bufferevent bev;
  138. /** Evbuffer callback to enforce watermarks on input. */
  139. struct evbuffer_cb_entry *read_watermarks_cb;
  140. /** If set, we should free the lock when we free the bufferevent. */
  141. unsigned own_lock : 1;
  142. /** Flag: set if we have deferred callbacks and a read callback is
  143. * pending. */
  144. unsigned readcb_pending : 1;
  145. /** Flag: set if we have deferred callbacks and a write callback is
  146. * pending. */
  147. unsigned writecb_pending : 1;
  148. /** Flag: set if we are currently busy connecting. */
  149. unsigned connecting : 1;
  150. /** Flag: set if a connect failed prematurely; this is a hack for
  151. * getting around the bufferevent abstraction. */
  152. unsigned connection_refused : 1;
  153. /** Set to the events pending if we have deferred callbacks and
  154. * an events callback is pending. */
  155. short eventcb_pending;
  156. /** If set, read is suspended until one or more conditions are over.
  157. * The actual value here is a bitfield of those conditions; see the
  158. * BEV_SUSPEND_* flags above. */
  159. bufferevent_suspend_flags read_suspended;
  160. /** If set, writing is suspended until one or more conditions are over.
  161. * The actual value here is a bitfield of those conditions; see the
  162. * BEV_SUSPEND_* flags above. */
  163. bufferevent_suspend_flags write_suspended;
  164. /** Set to the current socket errno if we have deferred callbacks and
  165. * an events callback is pending. */
  166. int errno_pending;
  167. /** The DNS error code for bufferevent_socket_connect_hostname */
  168. int dns_error;
  169. /** Used to implement deferred callbacks */
  170. struct event_callback deferred;
  171. /** The options this bufferevent was constructed with */
  172. enum bufferevent_options options;
  173. /** Current reference count for this bufferevent. */
  174. int refcnt;
  175. /** Lock for this bufferevent. Shared by the inbuf and the outbuf.
  176. * If NULL, locking is disabled. */
  177. void *lock;
  178. /** No matter how big our bucket gets, don't try to read more than this
  179. * much in a single read operation. */
  180. ev_ssize_t max_single_read;
  181. /** No matter how big our bucket gets, don't try to write more than this
  182. * much in a single write operation. */
  183. ev_ssize_t max_single_write;
  184. /** Rate-limiting information for this bufferevent */
  185. struct bufferevent_rate_limit *rate_limiting;
  186. /* Saved conn_addr, to extract IP address from it.
  187. *
  188. * Because some servers may reset/close connection without waiting clients,
  189. * in that case we can't extract IP address even in close_cb.
  190. * So we need to save it, just after we connected to remote server, or
  191. * after resolving (to avoid extra dns requests during retrying, since UDP
  192. * is slow) */
  193. union {
  194. struct sockaddr_in6 in6;
  195. struct sockaddr_in in;
  196. } conn_address;
  197. struct evdns_getaddrinfo_request *dns_request;
  198. };
  199. /** Possible operations for a control callback. */
  200. enum bufferevent_ctrl_op {
  201. BEV_CTRL_SET_FD,
  202. BEV_CTRL_GET_FD,
  203. BEV_CTRL_GET_UNDERLYING,
  204. BEV_CTRL_CANCEL_ALL
  205. };
  206. /** Possible data types for a control callback */
  207. union bufferevent_ctrl_data {
  208. void *ptr;
  209. evutil_socket_t fd;
  210. };
  211. /**
  212. Implementation table for a bufferevent: holds function pointers and other
  213. information to make the various bufferevent types work.
  214. */
  215. struct bufferevent_ops {
  216. /** The name of the bufferevent's type. */
  217. const char *type;
  218. /** At what offset into the implementation type will we find a
  219. bufferevent structure?
  220. Example: if the type is implemented as
  221. struct bufferevent_x {
  222. int extra_data;
  223. struct bufferevent bev;
  224. }
  225. then mem_offset should be offsetof(struct bufferevent_x, bev)
  226. */
  227. off_t mem_offset;
  228. /** Enables one or more of EV_READ|EV_WRITE on a bufferevent. Does
  229. not need to adjust the 'enabled' field. Returns 0 on success, -1
  230. on failure.
  231. */
  232. int (*enable)(struct bufferevent *, short);
  233. /** Disables one or more of EV_READ|EV_WRITE on a bufferevent. Does
  234. not need to adjust the 'enabled' field. Returns 0 on success, -1
  235. on failure.
  236. */
  237. int (*disable)(struct bufferevent *, short);
  238. /** Detatches the bufferevent from related data structures. Called as
  239. * soon as its reference count reaches 0. */
  240. void (*unlink)(struct bufferevent *);
  241. /** Free any storage and deallocate any extra data or structures used
  242. in this implementation. Called when the bufferevent is
  243. finalized.
  244. */
  245. void (*destruct)(struct bufferevent *);
  246. /** Called when the timeouts on the bufferevent have changed.*/
  247. int (*adj_timeouts)(struct bufferevent *);
  248. /** Called to flush data. */
  249. int (*flush)(struct bufferevent *, short, enum bufferevent_flush_mode);
  250. /** Called to access miscellaneous fields. */
  251. int (*ctrl)(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *);
  252. };
  253. extern const struct bufferevent_ops bufferevent_ops_socket;
  254. extern const struct bufferevent_ops bufferevent_ops_filter;
  255. extern const struct bufferevent_ops bufferevent_ops_pair;
  256. #define BEV_IS_SOCKET(bevp) ((bevp)->be_ops == &bufferevent_ops_socket)
  257. #define BEV_IS_FILTER(bevp) ((bevp)->be_ops == &bufferevent_ops_filter)
  258. #define BEV_IS_PAIR(bevp) ((bevp)->be_ops == &bufferevent_ops_pair)
  259. #if defined(EVENT__HAVE_OPENSSL)
  260. extern const struct bufferevent_ops bufferevent_ops_openssl;
  261. #define BEV_IS_OPENSSL(bevp) ((bevp)->be_ops == &bufferevent_ops_openssl)
  262. #else
  263. #define BEV_IS_OPENSSL(bevp) 0
  264. #endif
  265. #ifdef _WIN32
  266. extern const struct bufferevent_ops bufferevent_ops_async;
  267. #define BEV_IS_ASYNC(bevp) ((bevp)->be_ops == &bufferevent_ops_async)
  268. #else
  269. #define BEV_IS_ASYNC(bevp) 0
  270. #endif
  271. /** Initialize the shared parts of a bufferevent. */
  272. EVENT2_EXPORT_SYMBOL
  273. int bufferevent_init_common_(struct bufferevent_private *, struct event_base *, const struct bufferevent_ops *, enum bufferevent_options options);
  274. /** For internal use: temporarily stop all reads on bufev, until the conditions
  275. * in 'what' are over. */
  276. EVENT2_EXPORT_SYMBOL
  277. void bufferevent_suspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what);
  278. /** For internal use: clear the conditions 'what' on bufev, and re-enable
  279. * reading if there are no conditions left. */
  280. EVENT2_EXPORT_SYMBOL
  281. void bufferevent_unsuspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what);
  282. /** For internal use: temporarily stop all writes on bufev, until the conditions
  283. * in 'what' are over. */
  284. void bufferevent_suspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what);
  285. /** For internal use: clear the conditions 'what' on bufev, and re-enable
  286. * writing if there are no conditions left. */
  287. void bufferevent_unsuspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what);
  288. #define bufferevent_wm_suspend_read(b) \
  289. bufferevent_suspend_read_((b), BEV_SUSPEND_WM)
  290. #define bufferevent_wm_unsuspend_read(b) \
  291. bufferevent_unsuspend_read_((b), BEV_SUSPEND_WM)
  292. /*
  293. Disable a bufferevent. Equivalent to bufferevent_disable(), but
  294. first resets 'connecting' flag to force EV_WRITE down for sure.
  295. XXXX this method will go away in the future; try not to add new users.
  296. See comment in evhttp_connection_reset_() for discussion.
  297. @param bufev the bufferevent to be disabled
  298. @param event any combination of EV_READ | EV_WRITE.
  299. @return 0 if successful, or -1 if an error occurred
  300. @see bufferevent_disable()
  301. */
  302. EVENT2_EXPORT_SYMBOL
  303. int bufferevent_disable_hard_(struct bufferevent *bufev, short event);
  304. /** Internal: Set up locking on a bufferevent. If lock is set, use it.
  305. * Otherwise, use a new lock. */
  306. EVENT2_EXPORT_SYMBOL
  307. int bufferevent_enable_locking_(struct bufferevent *bufev, void *lock);
  308. /** Internal: backwards compat macro for the now public function
  309. * Increment the reference count on bufev. */
  310. #define bufferevent_incref_(bufev) bufferevent_incref(bufev)
  311. /** Internal: Lock bufev and increase its reference count.
  312. * unlocking it otherwise. */
  313. EVENT2_EXPORT_SYMBOL
  314. void bufferevent_incref_and_lock_(struct bufferevent *bufev);
  315. /** Internal: backwards compat macro for the now public function
  316. * Decrement the reference count on bufev. Returns 1 if it freed
  317. * the bufferevent.*/
  318. #define bufferevent_decref_(bufev) bufferevent_decref(bufev)
  319. /** Internal: Drop the reference count on bufev, freeing as necessary, and
  320. * unlocking it otherwise. Returns 1 if it freed the bufferevent. */
  321. EVENT2_EXPORT_SYMBOL
  322. int bufferevent_decref_and_unlock_(struct bufferevent *bufev);
  323. /** Internal: If callbacks are deferred and we have a read callback, schedule
  324. * a readcb. Otherwise just run the readcb. Ignores watermarks. */
  325. EVENT2_EXPORT_SYMBOL
  326. void bufferevent_run_readcb_(struct bufferevent *bufev, int options);
  327. /** Internal: If callbacks are deferred and we have a write callback, schedule
  328. * a writecb. Otherwise just run the writecb. Ignores watermarks. */
  329. EVENT2_EXPORT_SYMBOL
  330. void bufferevent_run_writecb_(struct bufferevent *bufev, int options);
  331. /** Internal: If callbacks are deferred and we have an eventcb, schedule
  332. * it to run with events "what". Otherwise just run the eventcb.
  333. * See bufferevent_trigger_event for meaning of "options". */
  334. EVENT2_EXPORT_SYMBOL
  335. void bufferevent_run_eventcb_(struct bufferevent *bufev, short what, int options);
  336. /** Internal: Run or schedule (if deferred or options contain
  337. * BEV_TRIG_DEFER_CALLBACKS) I/O callbacks specified in iotype.
  338. * Must already hold the bufev lock. Honors watermarks unless
  339. * BEV_TRIG_IGNORE_WATERMARKS is in options. */
  340. static inline void bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options);
  341. /* Making this inline since all of the common-case calls to this function in
  342. * libevent use constant arguments. */
  343. static inline void
  344. bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options)
  345. {
  346. if ((iotype & EV_READ) && ((options & BEV_TRIG_IGNORE_WATERMARKS) ||
  347. evbuffer_get_length(bufev->input) >= bufev->wm_read.low))
  348. bufferevent_run_readcb_(bufev, options);
  349. if ((iotype & EV_WRITE) && ((options & BEV_TRIG_IGNORE_WATERMARKS) ||
  350. evbuffer_get_length(bufev->output) <= bufev->wm_write.low))
  351. bufferevent_run_writecb_(bufev, options);
  352. }
  353. /** Internal: Add the event 'ev' with timeout tv, unless tv is set to 0, in
  354. * which case add ev with no timeout. */
  355. EVENT2_EXPORT_SYMBOL
  356. int bufferevent_add_event_(struct event *ev, const struct timeval *tv);
  357. /* =========
  358. * These next functions implement timeouts for bufferevents that aren't doing
  359. * anything else with ev_read and ev_write, to handle timeouts.
  360. * ========= */
  361. /** Internal use: Set up the ev_read and ev_write callbacks so that
  362. * the other "generic_timeout" functions will work on it. Call this from
  363. * the constructor function. */
  364. EVENT2_EXPORT_SYMBOL
  365. void bufferevent_init_generic_timeout_cbs_(struct bufferevent *bev);
  366. /** Internal use: Add or delete the generic timeout events as appropriate.
  367. * (If an event is enabled and a timeout is set, we add the event. Otherwise
  368. * we delete it.) Call this from anything that changes the timeout values,
  369. * that enabled EV_READ or EV_WRITE, or that disables EV_READ or EV_WRITE. */
  370. EVENT2_EXPORT_SYMBOL
  371. int bufferevent_generic_adj_timeouts_(struct bufferevent *bev);
  372. EVENT2_EXPORT_SYMBOL
  373. int bufferevent_generic_adj_existing_timeouts_(struct bufferevent *bev);
  374. EVENT2_EXPORT_SYMBOL
  375. enum bufferevent_options bufferevent_get_options_(struct bufferevent *bev);
  376. EVENT2_EXPORT_SYMBOL
  377. const struct sockaddr*
  378. bufferevent_socket_get_conn_address_(struct bufferevent *bev);
  379. EVENT2_EXPORT_SYMBOL
  380. void
  381. bufferevent_socket_set_conn_address_fd_(struct bufferevent *bev, evutil_socket_t fd);
  382. EVENT2_EXPORT_SYMBOL
  383. void
  384. bufferevent_socket_set_conn_address_(struct bufferevent *bev, struct sockaddr *addr, size_t addrlen);
  385. /** Internal use: We have just successfully read data into an inbuf, so
  386. * reset the read timeout (if any). */
  387. #define BEV_RESET_GENERIC_READ_TIMEOUT(bev) \
  388. do { \
  389. if (evutil_timerisset(&(bev)->timeout_read)) \
  390. event_add(&(bev)->ev_read, &(bev)->timeout_read); \
  391. } while (0)
  392. /** Internal use: We have just successfully written data from an inbuf, so
  393. * reset the read timeout (if any). */
  394. #define BEV_RESET_GENERIC_WRITE_TIMEOUT(bev) \
  395. do { \
  396. if (evutil_timerisset(&(bev)->timeout_write)) \
  397. event_add(&(bev)->ev_write, &(bev)->timeout_write); \
  398. } while (0)
  399. #define BEV_DEL_GENERIC_READ_TIMEOUT(bev) \
  400. event_del(&(bev)->ev_read)
  401. #define BEV_DEL_GENERIC_WRITE_TIMEOUT(bev) \
  402. event_del(&(bev)->ev_write)
  403. /** Internal: Given a bufferevent, return its corresponding
  404. * bufferevent_private. */
  405. #define BEV_UPCAST(b) EVUTIL_UPCAST((b), struct bufferevent_private, bev)
  406. #ifdef EVENT__DISABLE_THREAD_SUPPORT
  407. #define BEV_LOCK(b) EVUTIL_NIL_STMT_
  408. #define BEV_UNLOCK(b) EVUTIL_NIL_STMT_
  409. #else
  410. /** Internal: Grab the lock (if any) on a bufferevent */
  411. #define BEV_LOCK(b) do { \
  412. struct bufferevent_private *locking = BEV_UPCAST(b); \
  413. EVLOCK_LOCK(locking->lock, 0); \
  414. } while (0)
  415. /** Internal: Release the lock (if any) on a bufferevent */
  416. #define BEV_UNLOCK(b) do { \
  417. struct bufferevent_private *locking = BEV_UPCAST(b); \
  418. EVLOCK_UNLOCK(locking->lock, 0); \
  419. } while (0)
  420. #endif
  421. /* ==== For rate-limiting. */
  422. EVENT2_EXPORT_SYMBOL
  423. int bufferevent_decrement_write_buckets_(struct bufferevent_private *bev,
  424. ev_ssize_t bytes);
  425. EVENT2_EXPORT_SYMBOL
  426. int bufferevent_decrement_read_buckets_(struct bufferevent_private *bev,
  427. ev_ssize_t bytes);
  428. EVENT2_EXPORT_SYMBOL
  429. ev_ssize_t bufferevent_get_read_max_(struct bufferevent_private *bev);
  430. EVENT2_EXPORT_SYMBOL
  431. ev_ssize_t bufferevent_get_write_max_(struct bufferevent_private *bev);
  432. int bufferevent_ratelim_init_(struct bufferevent_private *bev);
  433. #ifdef __cplusplus
  434. }
  435. #endif
  436. #endif /* BUFFEREVENT_INTERNAL_H_INCLUDED_ */