Lines Matching refs:bev
80 struct bufferevent_private bev; member
93 evutil_offsetof(struct bufferevent_async, bev.bev),
104 upcast(struct bufferevent *bev) in upcast() argument
107 if (bev->be_ops != &bufferevent_ops_async) in upcast()
109 bev_a = EVUTIL_UPCAST(bev, struct bufferevent_async, bev.bev); in upcast()
118 EVUTIL_ASSERT(BEV_IS_ASYNC(&bev_a->bev.bev)); in upcast_connect()
127 EVUTIL_ASSERT(BEV_IS_ASYNC(&bev_a->bev.bev)); in upcast_read()
136 EVUTIL_ASSERT(BEV_IS_ASYNC(&bev_a->bev.bev)); in upcast_write()
143 struct bufferevent *bev = &beva->bev.bev; in bev_async_del_write() local
147 event_base_del_virtual_(bev->ev_base); in bev_async_del_write()
154 struct bufferevent *bev = &beva->bev.bev; in bev_async_del_read() local
158 event_base_del_virtual_(bev->ev_base); in bev_async_del_read()
165 struct bufferevent *bev = &beva->bev.bev; in bev_async_add_write() local
169 event_base_add_virtual_(bev->ev_base); in bev_async_add_write()
176 struct bufferevent *bev = &beva->bev.bev; in bev_async_add_read() local
180 event_base_add_virtual_(bev->ev_base); in bev_async_add_read()
189 struct bufferevent *bev = &beva->bev.bev; in bev_async_consider_writing() local
193 if (beva->write_in_progress || beva->bev.connecting) in bev_async_consider_writing()
195 if (!beva->ok || !(bev->enabled&EV_WRITE) || in bev_async_consider_writing()
196 !evbuffer_get_length(bev->output)) { in bev_async_consider_writing()
201 at_most = evbuffer_get_length(bev->output); in bev_async_consider_writing()
205 limit = (int)bufferevent_get_write_max_(&beva->bev); in bev_async_consider_writing()
209 if (beva->bev.write_suspended) { in bev_async_consider_writing()
215 bufferevent_incref_(bev); in bev_async_consider_writing()
216 if (evbuffer_launch_write_(bev->output, at_most, in bev_async_consider_writing()
218 bufferevent_decref_(bev); in bev_async_consider_writing()
220 bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR, 0); in bev_async_consider_writing()
223 bufferevent_decrement_write_buckets_(&beva->bev, at_most); in bev_async_consider_writing()
235 struct bufferevent *bev = &beva->bev.bev; in bev_async_consider_reading() local
239 if (beva->read_in_progress || beva->bev.connecting) in bev_async_consider_reading()
241 if (!beva->ok || !(bev->enabled&EV_READ)) { in bev_async_consider_reading()
247 cur_size = evbuffer_get_length(bev->input); in bev_async_consider_reading()
248 read_high = bev->wm_read.high; in bev_async_consider_reading()
261 limit = (int)bufferevent_get_read_max_(&beva->bev); in bev_async_consider_reading()
265 if (beva->bev.read_suspended) { in bev_async_consider_reading()
270 bufferevent_incref_(bev); in bev_async_consider_reading()
271 if (evbuffer_launch_read_(bev->input, at_most, &beva->read_overlapped)) { in bev_async_consider_reading()
273 bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR, 0); in bev_async_consider_reading()
274 bufferevent_decref_(bev); in bev_async_consider_reading()
277 bufferevent_decrement_read_buckets_(&beva->bev, at_most); in bev_async_consider_reading()
289 struct bufferevent *bev = arg; in be_async_outbuf_callback() local
290 struct bufferevent_async *bev_async = upcast(bev); in be_async_outbuf_callback()
295 bufferevent_incref_and_lock_(bev); in be_async_outbuf_callback()
300 bufferevent_decref_and_unlock_(bev); in be_async_outbuf_callback()
308 struct bufferevent *bev = arg; in be_async_inbuf_callback() local
309 struct bufferevent_async *bev_async = upcast(bev); in be_async_inbuf_callback()
314 bufferevent_incref_and_lock_(bev); in be_async_inbuf_callback()
319 bufferevent_decref_and_unlock_(bev); in be_async_inbuf_callback()
330 if (bev_async->bev.connecting) { in be_async_enable()
351 be_async_disable(struct bufferevent *bev, short what) in be_async_disable() argument
353 struct bufferevent_async *bev_async = upcast(bev); in be_async_disable()
359 BEV_DEL_GENERIC_READ_TIMEOUT(bev); in be_async_disable()
363 BEV_DEL_GENERIC_WRITE_TIMEOUT(bev); in be_async_disable()
371 be_async_destruct(struct bufferevent *bev) in be_async_destruct() argument
373 struct bufferevent_async *bev_async = upcast(bev); in be_async_destruct()
374 struct bufferevent_private *bev_p = BEV_UPCAST(bev); in be_async_destruct()
377 EVUTIL_ASSERT(!upcast(bev)->write_in_progress && in be_async_destruct()
378 !upcast(bev)->read_in_progress); in be_async_destruct()
383 fd = evbuffer_overlapped_get_fd_(bev->input); in be_async_destruct()
387 evbuffer_overlapped_set_fd_(bev->input, INVALID_SOCKET); in be_async_destruct()
394 bev_async_set_wsa_error(struct bufferevent *bev, struct event_overlapped *eo) in bev_async_set_wsa_error() argument
399 fd = evbuffer_overlapped_get_fd_(bev->input); in bev_async_set_wsa_error()
404 be_async_flush(struct bufferevent *bev, short what, in be_async_flush() argument
415 struct bufferevent *bev = &bev_a->bev.bev; in connect_complete() local
418 BEV_LOCK(bev); in connect_complete()
420 EVUTIL_ASSERT(bev_a->bev.connecting); in connect_complete()
421 bev_a->bev.connecting = 0; in connect_complete()
422 sock = evbuffer_overlapped_get_fd_(bev_a->bev.bev.input); in connect_complete()
427 bufferevent_async_set_connected_(bev); in connect_complete()
429 bev_async_set_wsa_error(bev, eo); in connect_complete()
431 bufferevent_run_eventcb_(bev, in connect_complete()
434 event_base_del_virtual_(bev->ev_base); in connect_complete()
436 bufferevent_decref_and_unlock_(bev); in connect_complete()
444 struct bufferevent *bev = &bev_a->bev.bev; in read_complete() local
447 BEV_LOCK(bev); in read_complete()
451 evbuffer_commit_read_(bev->input, nbytes); in read_complete()
454 bufferevent_decrement_read_buckets_(&bev_a->bev, -amount_unread); in read_complete()
457 bev_async_set_wsa_error(bev, eo); in read_complete()
461 BEV_RESET_GENERIC_READ_TIMEOUT(bev); in read_complete()
462 bufferevent_trigger_nolock_(bev, EV_READ, 0); in read_complete()
467 bufferevent_run_eventcb_(bev, what, 0); in read_complete()
471 bufferevent_run_eventcb_(bev, what, 0); in read_complete()
475 bufferevent_decref_and_unlock_(bev); in read_complete()
483 struct bufferevent *bev = &bev_a->bev.bev; in write_complete() local
487 BEV_LOCK(bev); in write_complete()
491 evbuffer_commit_write_(bev->output, nbytes); in write_complete()
495 bufferevent_decrement_write_buckets_(&bev_a->bev, in write_complete()
500 bev_async_set_wsa_error(bev, eo); in write_complete()
504 BEV_RESET_GENERIC_WRITE_TIMEOUT(bev); in write_complete()
505 bufferevent_trigger_nolock_(bev, EV_WRITE, 0); in write_complete()
510 bufferevent_run_eventcb_(bev, what, 0); in write_complete()
514 bufferevent_run_eventcb_(bev, what, 0); in write_complete()
518 bufferevent_decref_and_unlock_(bev); in write_complete()
526 struct bufferevent *bev; in bufferevent_async_new_() local
546 bev = &bev_a->bev.bev; in bufferevent_async_new_()
547 if (!(bev->input = evbuffer_overlapped_new_(fd))) { in bufferevent_async_new_()
551 if (!(bev->output = evbuffer_overlapped_new_(fd))) { in bufferevent_async_new_()
552 evbuffer_free(bev->input); in bufferevent_async_new_()
557 if (bufferevent_init_common_(&bev_a->bev, base, &bufferevent_ops_async, in bufferevent_async_new_()
561 evbuffer_add_cb(bev->input, be_async_inbuf_callback, bev); in bufferevent_async_new_()
562 evbuffer_add_cb(bev->output, be_async_outbuf_callback, bev); in bufferevent_async_new_()
568 bufferevent_init_generic_timeout_cbs_(bev); in bufferevent_async_new_()
572 return bev; in bufferevent_async_new_()
574 bufferevent_free(&bev_a->bev.bev); in bufferevent_async_new_()
579 bufferevent_async_set_connected_(struct bufferevent *bev) in bufferevent_async_set_connected_() argument
581 struct bufferevent_async *bev_async = upcast(bev); in bufferevent_async_set_connected_()
583 bufferevent_init_generic_timeout_cbs_(bev); in bufferevent_async_set_connected_()
585 be_async_enable(bev, bev->enabled); in bufferevent_async_set_connected_()
589 bufferevent_async_can_connect_(struct bufferevent *bev) in bufferevent_async_can_connect_() argument
594 if (BEV_IS_ASYNC(bev) && in bufferevent_async_can_connect_()
595 event_base_get_iocp_(bev->ev_base) && in bufferevent_async_can_connect_()
603 bufferevent_async_connect_(struct bufferevent *bev, evutil_socket_t fd, in bufferevent_async_connect_() argument
607 struct bufferevent_async *bev_async = upcast(bev); in bufferevent_async_connect_()
635 event_base_add_virtual_(bev->ev_base); in bufferevent_async_connect_()
636 bufferevent_incref_(bev); in bufferevent_async_connect_()
642 event_base_del_virtual_(bev->ev_base); in bufferevent_async_connect_()
643 bufferevent_decref_(bev); in bufferevent_async_connect_()
649 be_async_ctrl(struct bufferevent *bev, enum bufferevent_ctrl_op op, in be_async_ctrl() argument
654 data->fd = evbuffer_overlapped_get_fd_(bev->input); in be_async_ctrl()
659 if (data->fd == evbuffer_overlapped_get_fd_(bev->input)) in be_async_ctrl()
661 if (!(iocp = event_base_get_iocp_(bev->ev_base))) in be_async_ctrl()
665 evbuffer_overlapped_set_fd_(bev->input, data->fd); in be_async_ctrl()
666 evbuffer_overlapped_set_fd_(bev->output, data->fd); in be_async_ctrl()
670 struct bufferevent_async *bev_a = upcast(bev); in be_async_ctrl()
671 evutil_socket_t fd = evbuffer_overlapped_get_fd_(bev->input); in be_async_ctrl()
673 (bev_a->bev.options & BEV_OPT_CLOSE_ON_FREE)) { in be_async_ctrl()
675 evbuffer_overlapped_set_fd_(bev->input, INVALID_SOCKET); in be_async_ctrl()