26 #ifndef BUFFEREVENT_INTERNAL_H_INCLUDED_
27 #define BUFFEREVENT_INTERNAL_H_INCLUDED_
33 #include "event2/event-config.h"
35 #include "evconfig-private.h"
37 #include "defer-internal.h"
38 #include "evthread-internal.h"
40 #include "ratelim-internal.h"
47 #ifdef EVENT__HAVE_NETINET_IN_H
48 #include <netinet/in.h>
50 #ifdef EVENT__HAVE_NETINET_IN6_H
51 #include <netinet/in6.h>
65 #define BEV_SUSPEND_WM 0x01
67 #define BEV_SUSPEND_BW 0x02
69 #define BEV_SUSPEND_BW_GROUP 0x04
72 #define BEV_SUSPEND_LOOKUP 0x08
75 #define BEV_SUSPEND_FILT_READ 0x10
77 typedef ev_uint16_t bufferevent_suspend_flags;
105 ev_uint64_t total_written;
114 ev_ssize_t configured_min_share;
149 struct event refill_bucket_event;
229 struct sockaddr_in in;
236 enum bufferevent_ctrl_op {
239 BEV_CTRL_GET_UNDERLYING,
305 #define BEV_IS_SOCKET(bevp) ((bevp)->be_ops == &bufferevent_ops_socket)
306 #define BEV_IS_FILTER(bevp) ((bevp)->be_ops == &bufferevent_ops_filter)
307 #define BEV_IS_PAIR(bevp) ((bevp)->be_ops == &bufferevent_ops_pair)
309 #if defined(EVENT__HAVE_OPENSSL)
311 #define BEV_IS_OPENSSL(bevp) ((bevp)->be_ops == &bufferevent_ops_openssl)
313 #define BEV_IS_OPENSSL(bevp) 0
318 #define BEV_IS_ASYNC(bevp) ((bevp)->be_ops == &bufferevent_ops_async)
320 #define BEV_IS_ASYNC(bevp) 0
330 void bufferevent_suspend_read_(
struct bufferevent *bufev, bufferevent_suspend_flags what);
334 void bufferevent_unsuspend_read_(
struct bufferevent *bufev, bufferevent_suspend_flags what);
338 void bufferevent_suspend_write_(
struct bufferevent *bufev, bufferevent_suspend_flags what);
341 void bufferevent_unsuspend_write_(
struct bufferevent *bufev, bufferevent_suspend_flags what);
343 #define bufferevent_wm_suspend_read(b) \
344 bufferevent_suspend_read_((b), BEV_SUSPEND_WM)
345 #define bufferevent_wm_unsuspend_read(b) \
346 bufferevent_unsuspend_read_((b), BEV_SUSPEND_WM)
366 int bufferevent_enable_locking_(
struct bufferevent *bufev,
void *lock);
369 #define bufferevent_incref_(bufev) bufferevent_incref(bufev)
373 void bufferevent_incref_and_lock_(
struct bufferevent *bufev);
377 #define bufferevent_decref_(bufev) bufferevent_decref(bufev)
382 int bufferevent_decref_and_unlock_(
struct bufferevent *bufev);
402 static inline void bufferevent_trigger_nolock_(
struct bufferevent *bufev,
short iotype,
int options);
411 bufferevent_run_readcb_(bufev,
options);
414 bufferevent_run_writecb_(bufev,
options);
420 int bufferevent_add_event_(
struct event *ev,
const struct timeval *tv);
430 void bufferevent_init_generic_timeout_cbs_(
struct bufferevent *bev);
436 int bufferevent_generic_adj_timeouts_(
struct bufferevent *bev);
438 int bufferevent_generic_adj_existing_timeouts_(
struct bufferevent *bev);
444 const struct sockaddr*
445 bufferevent_socket_get_conn_address_(
struct bufferevent *bev);
453 bufferevent_socket_set_conn_address_(
struct bufferevent *bev,
struct sockaddr *addr,
size_t addrlen);
458 #define BEV_RESET_GENERIC_READ_TIMEOUT(bev) \
460 if (evutil_timerisset(&(bev)->timeout_read)) \
461 event_add(&(bev)->ev_read, &(bev)->timeout_read); \
465 #define BEV_RESET_GENERIC_WRITE_TIMEOUT(bev) \
467 if (evutil_timerisset(&(bev)->timeout_write)) \
468 event_add(&(bev)->ev_write, &(bev)->timeout_write); \
470 #define BEV_DEL_GENERIC_READ_TIMEOUT(bev) \
471 event_del(&(bev)->ev_read)
472 #define BEV_DEL_GENERIC_WRITE_TIMEOUT(bev) \
473 event_del(&(bev)->ev_write)
478 #define BEV_UPCAST(b) EVUTIL_UPCAST((b), struct bufferevent_private, bev)
480 #ifdef EVENT__DISABLE_THREAD_SUPPORT
481 #define BEV_LOCK(b) EVUTIL_NIL_STMT_
482 #define BEV_UNLOCK(b) EVUTIL_NIL_STMT_
485 #define BEV_LOCK(b) do { \
486 struct bufferevent_private *locking = BEV_UPCAST(b); \
487 EVLOCK_LOCK(locking->lock, 0); \
491 #define BEV_UNLOCK(b) do { \
492 struct bufferevent_private *locking = BEV_UPCAST(b); \
493 EVLOCK_UNLOCK(locking->lock, 0); \
EVENT2_EXPORT_SYMBOL size_t evbuffer_get_length(const struct evbuffer *buf)
Definition: buffer.c:607
@ BEV_TRIG_IGNORE_WATERMARKS
Definition: bufferevent.h:624
bufferevent_options
Definition: bufferevent.h:153
bufferevent_flush_mode
Definition: bufferevent.h:594
#define EV_WRITE
Definition: event.h:913
#define EV_READ
Definition: event.h:911
Definition: bufferevent-internal.h:253
void(* unlink)(struct bufferevent *)
Definition: bufferevent-internal.h:282
int(* disable)(struct bufferevent *, short)
Definition: bufferevent-internal.h:278
int(* enable)(struct bufferevent *, short)
Definition: bufferevent-internal.h:272
const char * type
Definition: bufferevent-internal.h:255
int(* adj_timeouts)(struct bufferevent *)
Definition: bufferevent-internal.h:291
void(* destruct)(struct bufferevent *)
Definition: bufferevent-internal.h:288
int(* ctrl)(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *)
Definition: bufferevent-internal.h:297
int(* flush)(struct bufferevent *, short, enum bufferevent_flush_mode)
Definition: bufferevent-internal.h:294
off_t mem_offset
Definition: bufferevent-internal.h:266
Definition: bufferevent-internal.h:154
unsigned own_lock
Definition: bufferevent-internal.h:162
bufferevent_suspend_flags write_suspended
Definition: bufferevent-internal.h:187
short eventcb_pending
Definition: bufferevent-internal.h:177
unsigned connecting
Definition: bufferevent-internal.h:171
ev_ssize_t max_single_read
Definition: bufferevent-internal.h:211
ev_ssize_t max_single_write
Definition: bufferevent-internal.h:215
int refcnt
Definition: bufferevent-internal.h:203
struct bufferevent_rate_limit * rate_limiting
Definition: bufferevent-internal.h:218
struct event_callback deferred
Definition: bufferevent-internal.h:197
struct evbuffer_cb_entry * read_watermarks_cb
Definition: bufferevent-internal.h:159
bufferevent_suspend_flags read_suspended
Definition: bufferevent-internal.h:182
enum bufferevent_options options
Definition: bufferevent-internal.h:200
unsigned connection_refused
Definition: bufferevent-internal.h:174
struct bufferevent bev
Definition: bufferevent-internal.h:156
unsigned readcb_pending
Definition: bufferevent-internal.h:166
int errno_pending
Definition: bufferevent-internal.h:191
int dns_error
Definition: bufferevent-internal.h:194
unsigned writecb_pending
Definition: bufferevent-internal.h:169
void * lock
Definition: bufferevent-internal.h:207
Definition: bufferevent-internal.h:79
unsigned pending_unsuspend_write
Definition: bufferevent-internal.h:99
int n_members
Definition: bufferevent-internal.h:109
struct evutil_weakrand_state weakrand_seed
Definition: bufferevent-internal.h:121
void * lock
Definition: bufferevent-internal.h:126
ev_ssize_t min_share
Definition: bufferevent-internal.h:113
struct event master_refill_event
Definition: bufferevent-internal.h:118
LIST_HEAD(rlim_group_member_list, bufferevent_private) members
unsigned read_suspended
Definition: bufferevent-internal.h:88
struct ev_token_bucket rate_limit
Definition: bufferevent-internal.h:83
unsigned write_suspended
Definition: bufferevent-internal.h:91
unsigned pending_unsuspend_read
Definition: bufferevent-internal.h:95
ev_uint64_t total_read
Definition: bufferevent-internal.h:104
Definition: bufferevent-internal.h:130
struct bufferevent_rate_limit_group * group
Definition: bufferevent-internal.h:139
Definition: bufferevent_struct.h:70
struct evbuffer * input
Definition: bufferevent_struct.h:88
struct evbuffer * output
Definition: bufferevent_struct.h:92
Definition: ratelim-internal.h:48
Definition: ratelim-internal.h:38
Definition: evbuffer-internal.h:62
Definition: event-internal.h:208
Definition: event_struct.h:107
Definition: event_struct.h:123
Definition: util-internal.h:315
Definition: http-server.c:102
Definition: ipv6-internal.h:63
Definition: bufferevent-internal.h:244
#define evutil_socket_t
Definition: util.h:310