Home | History | Annotate | Download | only in libevent

Lines Matching defs:bufev

66 bufferevent_suspend_read(struct bufferevent *bufev, bufferevent_suspend_flags what)
69 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
70 BEV_LOCK(bufev);
72 bufev->be_ops->disable(bufev, EV_READ);
74 BEV_UNLOCK(bufev);
78 bufferevent_unsuspend_read(struct bufferevent *bufev, bufferevent_suspend_flags what)
81 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
82 BEV_LOCK(bufev);
84 if (!bufev_private->read_suspended && (bufev->enabled & EV_READ))
85 bufev->be_ops->enable(bufev, EV_READ);
86 BEV_UNLOCK(bufev);
90 bufferevent_suspend_write(struct bufferevent *bufev, bufferevent_suspend_flags what)
93 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
94 BEV_LOCK(bufev);
96 bufev->be_ops->disable(bufev, EV_WRITE);
98 BEV_UNLOCK(bufev);
102 bufferevent_unsuspend_write(struct bufferevent *bufev, bufferevent_suspend_flags what)
105 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
106 BEV_LOCK(bufev);
108 if (!bufev_private->write_suspended && (bufev->enabled & EV_WRITE))
109 bufev->be_ops->enable(bufev, EV_WRITE);
110 BEV_UNLOCK(bufev);
121 struct bufferevent *bufev = arg;
126 if (size >= bufev->wm_read.high)
127 bufferevent_wm_suspend_read(bufev);
129 bufferevent_wm_unsuspend_read(bufev);
136 struct bufferevent *bufev = &bufev_private->bev;
138 BEV_LOCK(bufev);
140 bufev->errorcb) {
144 bufev->errorcb(bufev, BEV_EVENT_CONNECTED, bufev->cbarg);
146 if (bufev_private->readcb_pending && bufev->readcb) {
148 bufev->readcb(bufev, bufev->cbarg);
150 if (bufev_private->writecb_pending && bufev->writecb) {
152 bufev->writecb(bufev, bufev->cbarg);
154 if (bufev_private->eventcb_pending && bufev->errorcb) {
160 bufev->errorcb(bufev, what, bufev->cbarg);
162 _bufferevent_decref_and_unlock(bufev);
169 struct bufferevent *bufev = &bufev_private->bev;
171 BEV_LOCK(bufev);
173 do { BEV_UNLOCK(bufev); stmt; BEV_LOCK(bufev); } while(0)
176 bufev->errorcb) {
179 bufferevent_event_cb errorcb = bufev->errorcb;
180 void *cbarg = bufev->cbarg;
182 UNLOCKED(errorcb(bufev, BEV_EVENT_CONNECTED, cbarg));
184 if (bufev_private->readcb_pending && bufev->readcb) {
185 bufferevent_data_cb readcb = bufev->readcb;
186 void *cbarg = bufev->cbarg;
188 UNLOCKED(readcb(bufev, cbarg));
190 if (bufev_private->writecb_pending && bufev->writecb) {
191 bufferevent_data_cb writecb = bufev->writecb;
192 void *cbarg = bufev->cbarg;
194 UNLOCKED(writecb(bufev, cbarg));
196 if (bufev_private->eventcb_pending && bufev->errorcb) {
197 bufferevent_event_cb errorcb = bufev->errorcb;
198 void *cbarg = bufev->cbarg;
204 UNLOCKED(errorcb(bufev,what,cbarg));
206 _bufferevent_decref_and_unlock(bufev);
220 _bufferevent_run_readcb(struct bufferevent *bufev)
224 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
225 if (bufev->readcb == NULL)
232 bufev->readcb(bufev, bufev->cbarg);
237 _bufferevent_run_writecb(struct bufferevent *bufev)
241 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
242 if (bufev->writecb == NULL)
249 bufev->writecb(bufev, bufev->cbarg);
254 _bufferevent_run_eventcb(struct bufferevent *bufev, short what)
258 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
259 if (bufev->errorcb == NULL)
267 bufev->errorcb(bufev, what, bufev->cbarg);
277 struct bufferevent *bufev = &bufev_private->bev;
279 if (!bufev->input) {
280 if ((bufev->input = evbuffer_new()) == NULL)
284 if (!bufev->output) {
285 if ((bufev->output = evbuffer_new()) == NULL) {
286 evbuffer_free(bufev->input);
292 bufev->ev_base = base;
295 evutil_timerclear(&bufev->timeout_read);
296 evutil_timerclear(&bufev->timeout_write);
298 bufev->be_ops = ops;
305 bufev->enabled = EV_WRITE;
309 if (bufferevent_enable_locking(bufev, NULL) < 0) {
311 evbuffer_free(bufev->input);
312 evbuffer_free(bufev->output);
313 bufev->input = NULL;
314 bufev->output = NULL;
337 evbuffer_set_parent(bufev->input, bufev);
338 evbuffer_set_parent(bufev->output, bufev);
344 bufferevent_setcb(struct bufferevent *bufev,
348 BEV_LOCK(bufev);
350 bufev->readcb = readcb;
351 bufev->writecb = writecb;
352 bufev->errorcb = eventcb;
354 bufev->cbarg = cbarg;
355 BEV_UNLOCK(bufev);
359 bufferevent_get_input(struct bufferevent *bufev)
361 return bufev->input;
365 bufferevent_get_output(struct bufferevent *bufev)
367 return bufev->output;
371 bufferevent_get_base(struct bufferevent *bufev)
373 return bufev->ev_base;
377 bufferevent_write(struct bufferevent *bufev, const void *data, size_t size)
379 if (evbuffer_add(bufev->output, data, size) == -1)
386 bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf)
388 if (evbuffer_add_buffer(bufev->output, buf) == -1)
395 bufferevent_read(struct bufferevent *bufev, void *data, size_t size)
397 return (evbuffer_remove(bufev->input, data, size));
401 bufferevent_read_buffer(struct bufferevent *bufev, struct evbuffer *buf)
403 return (evbuffer_add_buffer(buf, bufev->input));
407 bufferevent_enable(struct bufferevent *bufev, short event)
410 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
414 _bufferevent_incref_and_lock(bufev);
420 bufev->enabled |= event;
422 if (impl_events && bufev->be_ops->enable(bufev, impl_events) < 0)
425 _bufferevent_decref_and_unlock(bufev);
430 bufferevent_set_timeouts(struct bufferevent *bufev,
435 BEV_LOCK(bufev);
437 bufev->timeout_read = *tv_read;
439 evutil_timerclear(&bufev->timeout_read);
442 bufev->timeout_write = *tv_write;
444 evutil_timerclear(&bufev->timeout_write);
447 if (bufev->be_ops->adj_timeouts)
448 r = bufev->be_ops->adj_timeouts(bufev);
449 BEV_UNLOCK(bufev);
457 bufferevent_settimeout(struct bufferevent *bufev,
475 bufferevent_set_timeouts(bufev, ptv_read, ptv_write);
480 bufferevent_disable_hard(struct bufferevent *bufev, short event)
484 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
486 BEV_LOCK(bufev);
487 bufev->enabled &= ~event;
490 if (bufev->be_ops->disable(bufev, event) < 0)
493 BEV_UNLOCK(bufev);
498 bufferevent_disable(struct bufferevent *bufev, short event)
502 BEV_LOCK(bufev);
503 bufev->enabled &= ~event;
505 if (bufev->be_ops->disable(bufev, event) < 0)
508 BEV_UNLOCK(bufev);
517 bufferevent_setwatermark(struct bufferevent *bufev, short events,
521 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
523 BEV_LOCK(bufev);
525 bufev->wm_write.low = lowmark;
526 bufev->wm_write.high = highmark;
530 bufev->wm_read.low = lowmark;
531 bufev->wm_read.high = highmark;
540 evbuffer_add_cb(bufev->input,
542 bufev);
544 evbuffer_cb_set_flags(bufev->input,
548 if (evbuffer_get_length(bufev->input) >= highmark)
549 bufferevent_wm_suspend_read(bufev);
550 else if (evbuffer_get_length(bufev->input) < highmark)
551 bufferevent_wm_unsuspend_read(bufev);
555 evbuffer_cb_clear_flags(bufev->input,
558 bufferevent_wm_unsuspend_read(bufev);
561 BEV_UNLOCK(bufev);
565 bufferevent_flush(struct bufferevent *bufev,
570 BEV_LOCK(bufev);
571 if (bufev->be_ops->flush)
572 r = bufev->be_ops->flush(bufev, iotype, mode);
573 BEV_UNLOCK(bufev);
578 _bufferevent_incref_and_lock(struct bufferevent *bufev)
581 BEV_UPCAST(bufev);
582 BEV_LOCK(bufev);
605 _bufferevent_decref_and_unlock(struct bufferevent *bufev)
608 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
614 BEV_UNLOCK(bufev);
618 underlying = bufferevent_get_underlying(bufev);
621 if (bufev->be_ops->destruct)
622 bufev->be_ops->destruct(bufev);
628 evbuffer_free(bufev->input);
629 evbuffer_free(bufev->output);
633 bufferevent_remove_from_rate_limit_group_internal(bufev,0);
641 event_debug_unassign(&bufev->ev_read);
642 event_debug_unassign(&bufev->ev_write);
644 BEV_UNLOCK(bufev);
650 mm_free(((char*)bufev) - bufev->be_ops->mem_offset);
669 bufferevent_decref(struct bufferevent *bufev)
671 BEV_LOCK(bufev);
672 return _bufferevent_decref_and_unlock(bufev);
676 bufferevent_free(struct bufferevent *bufev)
678 BEV_LOCK(bufev);
679 bufferevent_setcb(bufev, NULL, NULL, NULL, NULL);
680 _bufferevent_cancel_all(bufev);
681 _bufferevent_decref_and_unlock(bufev);
685 bufferevent_incref(struct bufferevent *bufev)
688 EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
690 BEV_LOCK(bufev);
692 BEV_UNLOCK(bufev);
696 bufferevent_enable_locking(struct bufferevent *bufev, void *lock)
703 if (BEV_UPCAST(bufev)->lock)
705 underlying = bufferevent_get_underlying(bufev);
709 BEV_UPCAST(bufev)->lock = lock;
710 BEV_UPCAST(bufev)->own_lock = 0;
715 BEV_UPCAST(bufev)->lock = lock;
716 BEV_UPCAST(bufev)->own_lock = 1;
718 BEV_UPCAST(bufev)->lock = lock;
719 BEV_UPCAST(bufev)->own_lock = 0;
721 evbuffer_enable_locking(bufev->input, lock);
722 evbuffer_enable_locking(bufev->output, lock);
769 bufferevent_get_enabled(struct bufferevent *bufev)
772 BEV_LOCK(bufev);
773 r = bufev->enabled;
774 BEV_UNLOCK(bufev);