unsigned connecting : 1;
/** Set to the events pending if we have deferred callbacks and
* an events callback is pending. */
- short errorcb_pending;
- /** Set to the current error if we have deferred callbacks and
+ short eventcb_pending;
+ /** Set to the current socket errno if we have deferred callbacks and
* an events callback is pending. */
int errno_pending;
/** Used to implement deferred callbacks */
void _bufferevent_run_writecb(struct bufferevent *bufev);
/** Internal: If callbacks are deferred and we have an eventcb, schedule
* it to run with events "what". Otherwise just run the eventcb. */
-void _bufferevent_run_errorcb(struct bufferevent *bufev, short what);
+void _bufferevent_run_eventcb(struct bufferevent *bufev, short what);
/* =========
* These next functions implement timeouts for bufferevents that aren't doing
bufev_private->writecb_pending = 0;
bufev->writecb(bufev, bufev->cbarg);
}
- if (bufev_private->errorcb_pending && bufev->errorcb) {
- short what = bufev_private->errorcb_pending;
+ if (bufev_private->eventcb_pending && bufev->errorcb) {
+ short what = bufev_private->eventcb_pending;
int err = bufev_private->errno_pending;
- bufev_private->errorcb_pending = 0;
+ bufev_private->eventcb_pending = 0;
bufev_private->errno_pending = 0;
EVUTIL_SET_SOCKET_ERROR(err);
bufev->errorcb(bufev, what, bufev->cbarg);
}
void
-_bufferevent_run_errorcb(struct bufferevent *bufev, short what)
+_bufferevent_run_eventcb(struct bufferevent *bufev, short what)
{
/* Requires lock. */
struct bufferevent_private *p =
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
if (p->options & BEV_OPT_DEFER_CALLBACKS) {
- p->errorcb_pending |= what;
+ p->eventcb_pending |= what;
p->errno_pending = EVUTIL_SOCKET_ERROR();
if (!p->deferred.queued) {
bufferevent_incref(bufev);
void
bufferevent_setcb(struct bufferevent *bufev,
bufferevent_data_cb readcb, bufferevent_data_cb writecb,
- bufferevent_event_cb errorcb, void *cbarg)
+ bufferevent_event_cb eventcb, void *cbarg)
{
BEV_LOCK(bufev);
bufev->readcb = readcb;
bufev->writecb = writecb;
- bufev->errorcb = errorcb;
+ bufev->errorcb = eventcb;
bufev->cbarg = cbarg;
BEV_UNLOCK(bufev);
bufferevent_generic_read_timeout_cb(evutil_socket_t fd, short event, void *ctx)
{
struct bufferevent *bev = ctx;
- _bufferevent_run_errorcb(bev, BEV_EVENT_TIMEOUT|BEV_EVENT_READING);
+ _bufferevent_run_eventcb(bev, BEV_EVENT_TIMEOUT|BEV_EVENT_READING);
}
static void
bufferevent_generic_write_timeout_cb(evutil_socket_t fd, short event, void *ctx)
{
struct bufferevent *bev = ctx;
- _bufferevent_run_errorcb(bev, BEV_EVENT_TIMEOUT|BEV_EVENT_WRITING);
+ _bufferevent_run_eventcb(bev, BEV_EVENT_TIMEOUT|BEV_EVENT_WRITING);
}
void
static void be_filter_readcb(struct bufferevent *, void *);
static void be_filter_writecb(struct bufferevent *, void *);
-static void be_filter_errorcb(struct bufferevent *, short, void *);
+static void be_filter_eventcb(struct bufferevent *, short, void *);
static int be_filter_flush(struct bufferevent *bufev,
short iotype, enum bufferevent_flush_mode mode);
static int be_filter_ctrl(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *);
bufev_f->context = ctx;
bufferevent_setcb(bufev_f->underlying,
- be_filter_readcb, be_filter_writecb, be_filter_errorcb, bufev_f);
+ be_filter_readcb, be_filter_writecb, be_filter_eventcb, bufev_f);
bufev_f->outbuf_cb = evbuffer_add_cb(downcast(bufev_f)->output,
bufferevent_filtered_outbuf_cb, bufev_f);
/* Called when the underlying socket has given us an error */
static void
-be_filter_errorcb(struct bufferevent *underlying, short what, void *_me)
+be_filter_eventcb(struct bufferevent *underlying, short what, void *_me)
{
struct bufferevent_filtered *bevf = _me;
struct bufferevent *bev = downcast(bevf);
- /* All we can really to is tell our own errorcb. */
+ /* All we can really to is tell our own eventcb. */
if (bev->errorcb)
- _bufferevent_run_errorcb(bev, what);
+ _bufferevent_run_eventcb(bev, what);
}
static int
error:
event_del(&bufev->ev_read);
- _bufferevent_run_errorcb(bufev, what);
+ _bufferevent_run_eventcb(bufev, what);
}
static void
}
if (bufev_p->connecting) {
bufev_p->connecting = 0;
- _bufferevent_run_errorcb(bufev, BEV_EVENT_CONNECTED);
+ _bufferevent_run_eventcb(bufev, BEV_EVENT_CONNECTED);
if (!(bufev->enabled & EV_WRITE)) {
event_del(&bufev->ev_write);
return;
error:
event_del(&bufev->ev_write);
- _bufferevent_run_errorcb(bufev, what);
+ _bufferevent_run_eventcb(bufev, what);
}
struct bufferevent *
return 0;
}
}
- _bufferevent_run_errorcb(bev, BEV_EVENT_ERROR);
+ _bufferevent_run_eventcb(bev, BEV_EVENT_ERROR);
/* do something about the error? */
} else {
/* The connect succeeded already. How odd. */
- _bufferevent_run_errorcb(bev, BEV_EVENT_CONNECTED);
+ _bufferevent_run_eventcb(bev, BEV_EVENT_CONNECTED);
}
return 0;
struct bufferevent *
bufferevent_new(evutil_socket_t fd,
bufferevent_data_cb readcb, bufferevent_data_cb writecb,
- bufferevent_event_cb errorcb, void *cbarg)
+ bufferevent_event_cb eventcb, void *cbarg)
{
struct bufferevent *bufev;
if (!(bufev = bufferevent_socket_new(NULL, fd, 0)))
return NULL;
- bufferevent_setcb(bufev, readcb, writecb, errorcb, cbarg);
+ bufferevent_setcb(bufev, readcb, writecb, eventcb, cbarg);
return bufev;
}
/**
Launch a connect() attempt with a socket. When the connect succeeds,
- the errorcb will be invoked with BEV_EVENT_CONNECTED set.
+ the eventcb will be invoked with BEV_EVENT_CONNECTED set.
If the bufferevent does not already have a socket set, we allocate a new
socket here and make it nonblocking before we begin.
no callback is desired
@param writecb callback to invoke when the file descriptor is ready for
writing, or NULL if no callback is desired
- @param errorcb callback to invoke when there is an error on the file
+ @param eventcb callback to invoke when there is an event on the file
descriptor
@param cbarg an argument that will be supplied to each of the callbacks
(readcb, writecb, and errorcb)
*/
void bufferevent_setcb(struct bufferevent *bufev,
bufferevent_data_cb readcb, bufferevent_data_cb writecb,
- bufferevent_event_cb errorcb, void *cbarg);
+ bufferevent_event_cb eventcb, void *cbarg);
/**
Changes the file descriptor on which the bufferevent operates.
bufferevent_data_cb readcb;
bufferevent_data_cb writecb;
+ /* This should be called 'eventcb', but renaming it would break
+ * backward compatibility */
bufferevent_event_cb errorcb;
void *cbarg;