Consistently say "eventcb" instead of "errorcb"

svn:r1316
This commit is contained in:
Nick Mathewson 2009-05-25 23:11:20 +00:00
parent 2f655f008c
commit 5232cfa357
6 changed files with 29 additions and 27 deletions

View File

@ -60,8 +60,8 @@ struct bufferevent_private {
unsigned connecting : 1; unsigned connecting : 1;
/** Set to the events pending if we have deferred callbacks and /** Set to the events pending if we have deferred callbacks and
* an events callback is pending. */ * an events callback is pending. */
short errorcb_pending; short eventcb_pending;
/** Set to the current error if we have deferred callbacks and /** Set to the current socket errno if we have deferred callbacks and
* an events callback is pending. */ * an events callback is pending. */
int errno_pending; int errno_pending;
/** Used to implement deferred callbacks */ /** Used to implement deferred callbacks */
@ -168,7 +168,7 @@ void _bufferevent_run_readcb(struct bufferevent *bufev);
void _bufferevent_run_writecb(struct bufferevent *bufev); void _bufferevent_run_writecb(struct bufferevent *bufev);
/** Internal: If callbacks are deferred and we have an eventcb, schedule /** Internal: If callbacks are deferred and we have an eventcb, schedule
* it to run with events "what". Otherwise just run the eventcb. */ * 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 * These next functions implement timeouts for bufferevents that aren't doing

View File

@ -129,10 +129,10 @@ bufferevent_run_deferred_callbacks(struct deferred_cb *_, void *arg)
bufev_private->writecb_pending = 0; bufev_private->writecb_pending = 0;
bufev->writecb(bufev, bufev->cbarg); bufev->writecb(bufev, bufev->cbarg);
} }
if (bufev_private->errorcb_pending && bufev->errorcb) { if (bufev_private->eventcb_pending && bufev->errorcb) {
short what = bufev_private->errorcb_pending; short what = bufev_private->eventcb_pending;
int err = bufev_private->errno_pending; int err = bufev_private->errno_pending;
bufev_private->errorcb_pending = 0; bufev_private->eventcb_pending = 0;
bufev_private->errno_pending = 0; bufev_private->errno_pending = 0;
EVUTIL_SET_SOCKET_ERROR(err); EVUTIL_SET_SOCKET_ERROR(err);
bufev->errorcb(bufev, what, bufev->cbarg); bufev->errorcb(bufev, what, bufev->cbarg);
@ -177,13 +177,13 @@ _bufferevent_run_writecb(struct bufferevent *bufev)
} }
void void
_bufferevent_run_errorcb(struct bufferevent *bufev, short what) _bufferevent_run_eventcb(struct bufferevent *bufev, short what)
{ {
/* Requires lock. */ /* Requires lock. */
struct bufferevent_private *p = struct bufferevent_private *p =
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
if (p->options & BEV_OPT_DEFER_CALLBACKS) { if (p->options & BEV_OPT_DEFER_CALLBACKS) {
p->errorcb_pending |= what; p->eventcb_pending |= what;
p->errno_pending = EVUTIL_SOCKET_ERROR(); p->errno_pending = EVUTIL_SOCKET_ERROR();
if (!p->deferred.queued) { if (!p->deferred.queued) {
bufferevent_incref(bufev); bufferevent_incref(bufev);
@ -253,13 +253,13 @@ bufferevent_init_common(struct bufferevent_private *bufev_private,
void void
bufferevent_setcb(struct bufferevent *bufev, bufferevent_setcb(struct bufferevent *bufev,
bufferevent_data_cb readcb, bufferevent_data_cb writecb, bufferevent_data_cb readcb, bufferevent_data_cb writecb,
bufferevent_event_cb errorcb, void *cbarg) bufferevent_event_cb eventcb, void *cbarg)
{ {
BEV_LOCK(bufev); BEV_LOCK(bufev);
bufev->readcb = readcb; bufev->readcb = readcb;
bufev->writecb = writecb; bufev->writecb = writecb;
bufev->errorcb = errorcb; bufev->errorcb = eventcb;
bufev->cbarg = cbarg; bufev->cbarg = cbarg;
BEV_UNLOCK(bufev); BEV_UNLOCK(bufev);
@ -574,13 +574,13 @@ static void
bufferevent_generic_read_timeout_cb(evutil_socket_t fd, short event, void *ctx) bufferevent_generic_read_timeout_cb(evutil_socket_t fd, short event, void *ctx)
{ {
struct bufferevent *bev = 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 static void
bufferevent_generic_write_timeout_cb(evutil_socket_t fd, short event, void *ctx) bufferevent_generic_write_timeout_cb(evutil_socket_t fd, short event, void *ctx)
{ {
struct bufferevent *bev = 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 void

View File

@ -66,7 +66,7 @@ static void be_filter_destruct(struct bufferevent *);
static void be_filter_readcb(struct bufferevent *, void *); static void be_filter_readcb(struct bufferevent *, void *);
static void be_filter_writecb(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, static int be_filter_flush(struct bufferevent *bufev,
short iotype, enum bufferevent_flush_mode mode); short iotype, enum bufferevent_flush_mode mode);
static int be_filter_ctrl(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *); static int be_filter_ctrl(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *);
@ -202,7 +202,7 @@ bufferevent_filter_new(struct bufferevent *underlying,
bufev_f->context = ctx; bufev_f->context = ctx;
bufferevent_setcb(bufev_f->underlying, 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, bufev_f->outbuf_cb = evbuffer_add_cb(downcast(bufev_f)->output,
bufferevent_filtered_outbuf_cb, bufev_f); bufferevent_filtered_outbuf_cb, bufev_f);
@ -410,14 +410,14 @@ be_filter_writecb(struct bufferevent *underlying, void *_me)
/* Called when the underlying socket has given us an error */ /* Called when the underlying socket has given us an error */
static void 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_filtered *bevf = _me;
struct bufferevent *bev = downcast(bevf); 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) if (bev->errorcb)
_bufferevent_run_errorcb(bev, what); _bufferevent_run_eventcb(bev, what);
} }
static int static int

View File

@ -173,7 +173,7 @@ bufferevent_readcb(evutil_socket_t fd, short event, void *arg)
error: error:
event_del(&bufev->ev_read); event_del(&bufev->ev_read);
_bufferevent_run_errorcb(bufev, what); _bufferevent_run_eventcb(bufev, what);
} }
static void static void
@ -191,7 +191,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
} }
if (bufev_p->connecting) { if (bufev_p->connecting) {
bufev_p->connecting = 0; bufev_p->connecting = 0;
_bufferevent_run_errorcb(bufev, BEV_EVENT_CONNECTED); _bufferevent_run_eventcb(bufev, BEV_EVENT_CONNECTED);
if (!(bufev->enabled & EV_WRITE)) { if (!(bufev->enabled & EV_WRITE)) {
event_del(&bufev->ev_write); event_del(&bufev->ev_write);
return; return;
@ -235,7 +235,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
error: error:
event_del(&bufev->ev_write); event_del(&bufev->ev_write);
_bufferevent_run_errorcb(bufev, what); _bufferevent_run_eventcb(bufev, what);
} }
struct bufferevent * struct bufferevent *
@ -302,11 +302,11 @@ bufferevent_socket_connect(struct bufferevent *bev,
return 0; return 0;
} }
} }
_bufferevent_run_errorcb(bev, BEV_EVENT_ERROR); _bufferevent_run_eventcb(bev, BEV_EVENT_ERROR);
/* do something about the error? */ /* do something about the error? */
} else { } else {
/* The connect succeeded already. How odd. */ /* The connect succeeded already. How odd. */
_bufferevent_run_errorcb(bev, BEV_EVENT_CONNECTED); _bufferevent_run_eventcb(bev, BEV_EVENT_CONNECTED);
} }
return 0; return 0;
@ -326,14 +326,14 @@ bufferevent_socket_connect(struct bufferevent *bev,
struct bufferevent * struct bufferevent *
bufferevent_new(evutil_socket_t fd, bufferevent_new(evutil_socket_t fd,
bufferevent_data_cb readcb, bufferevent_data_cb writecb, bufferevent_data_cb readcb, bufferevent_data_cb writecb,
bufferevent_event_cb errorcb, void *cbarg) bufferevent_event_cb eventcb, void *cbarg)
{ {
struct bufferevent *bufev; struct bufferevent *bufev;
if (!(bufev = bufferevent_socket_new(NULL, fd, 0))) if (!(bufev = bufferevent_socket_new(NULL, fd, 0)))
return NULL; return NULL;
bufferevent_setcb(bufev, readcb, writecb, errorcb, cbarg); bufferevent_setcb(bufev, readcb, writecb, eventcb, cbarg);
return bufev; return bufev;
} }

View File

@ -145,7 +145,7 @@ struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socke
/** /**
Launch a connect() attempt with a socket. When the connect succeeds, 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 If the bufferevent does not already have a socket set, we allocate a new
socket here and make it nonblocking before we begin. socket here and make it nonblocking before we begin.
@ -195,7 +195,7 @@ void bufferevent_free(struct bufferevent *bufev);
no callback is desired no callback is desired
@param writecb callback to invoke when the file descriptor is ready for @param writecb callback to invoke when the file descriptor is ready for
writing, or NULL if no callback is desired 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 descriptor
@param cbarg an argument that will be supplied to each of the callbacks @param cbarg an argument that will be supplied to each of the callbacks
(readcb, writecb, and errorcb) (readcb, writecb, and errorcb)
@ -203,7 +203,7 @@ void bufferevent_free(struct bufferevent *bufev);
*/ */
void bufferevent_setcb(struct bufferevent *bufev, void bufferevent_setcb(struct bufferevent *bufev,
bufferevent_data_cb readcb, bufferevent_data_cb writecb, 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. Changes the file descriptor on which the bufferevent operates.

View File

@ -99,6 +99,8 @@ struct bufferevent {
bufferevent_data_cb readcb; bufferevent_data_cb readcb;
bufferevent_data_cb writecb; bufferevent_data_cb writecb;
/* This should be called 'eventcb', but renaming it would break
* backward compatibility */
bufferevent_event_cb errorcb; bufferevent_event_cb errorcb;
void *cbarg; void *cbarg;