void
bufferevent_suspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what)
{
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
if (!bufev_private->read_suspended)
bufev->be_ops->disable(bufev, EV_READ);
void
bufferevent_unsuspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what)
{
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
bufev_private->read_suspended &= ~what;
if (!bufev_private->read_suspended && (bufev->enabled & EV_READ))
void
bufferevent_suspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what)
{
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
if (!bufev_private->write_suspended)
bufev->be_ops->disable(bufev, EV_WRITE);
void
bufferevent_unsuspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what)
{
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
bufev_private->write_suspended &= ~what;
if (!bufev_private->write_suspended && (bufev->enabled & EV_WRITE))
bufferevent_run_readcb_(struct bufferevent *bufev, int options)
{
/* Requires that we hold the lock and a reference */
- struct bufferevent_private *p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *p = BEV_UPCAST(bufev);
if (bufev->readcb == NULL)
return;
if ((p->options|options) & BEV_OPT_DEFER_CALLBACKS) {
bufferevent_run_writecb_(struct bufferevent *bufev, int options)
{
/* Requires that we hold the lock and a reference */
- struct bufferevent_private *p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *p = BEV_UPCAST(bufev);
if (bufev->writecb == NULL)
return;
if ((p->options|options) & BEV_OPT_DEFER_CALLBACKS) {
bufferevent_run_eventcb_(struct bufferevent *bufev, short what, int options)
{
/* Requires that we hold the lock and a reference */
- struct bufferevent_private *p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *p = BEV_UPCAST(bufev);
if (bufev->errorcb == NULL)
return;
if ((p->options|options) & BEV_OPT_DEFER_CALLBACKS) {
int
bufferevent_enable(struct bufferevent *bufev, short event)
{
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
short impl_events = event;
int r = 0;
bufferevent_disable_hard_(struct bufferevent *bufev, short event)
{
int r = 0;
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
bufev->enabled &= ~event;
bufferevent_setwatermark(struct bufferevent *bufev, short events,
size_t lowmark, size_t highmark)
{
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
if (events & EV_WRITE) {
void
bufferevent_incref_and_lock_(struct bufferevent *bufev)
{
- struct bufferevent_private *bufev_private =
- BEV_UPCAST(bufev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
++bufev_private->refcnt;
}
int
bufferevent_decref_and_unlock_(struct bufferevent *bufev)
{
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
int n_cbs = 0;
#define MAX_CBS 16
struct event_callback *cbs[MAX_CBS];
{
struct bufferevent *bufev = arg_;
struct bufferevent *underlying;
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
underlying = bufferevent_get_underlying(bufev);
void
bufferevent_incref(struct bufferevent *bufev)
{
- struct bufferevent_private *bufev_private =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
/* XXX: now that this function is public, we might want to
* - return the count from this function
enum bufferevent_options
bufferevent_get_options_(struct bufferevent *bev)
{
- struct bufferevent_private *bev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
+ struct bufferevent_private *bev_p = BEV_UPCAST(bev);
enum bufferevent_options options;
BEV_LOCK(bev);
bufferevent_generic_adj_timeouts_(struct bufferevent *bev)
{
const short enabled = bev->enabled;
- struct bufferevent_private *bev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
+ struct bufferevent_private *bev_p = BEV_UPCAST(bev);
int r1=0, r2=0;
if ((enabled & EV_READ) && !bev_p->read_suspended &&
evutil_timerisset(&bev->timeout_read))
const struct sockaddr*
bufferevent_socket_get_conn_address_(struct bufferevent *bev)
{
- struct bufferevent_private *bev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
-
+ struct bufferevent_private *bev_p = BEV_UPCAST(bev);
return (struct sockaddr *)&bev_p->conn_address;
}
void
bufferevent_socket_set_conn_address_fd_(struct bufferevent *bev, int fd)
{
- struct bufferevent_private *bev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
+ struct bufferevent_private *bev_p = BEV_UPCAST(bev);
socklen_t len = sizeof(bev_p->conn_address);
bufferevent_socket_set_conn_address_(struct bufferevent *bev,
struct sockaddr *addr, size_t addrlen)
{
- struct bufferevent_private *bev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
+ struct bufferevent_private *bev_p = BEV_UPCAST(bev);
EVUTIL_ASSERT(addrlen <= sizeof(bev_p->conn_address));
memcpy(&bev_p->conn_address, addr, addrlen);
}
void *arg)
{
struct bufferevent *bufev = arg;
- struct bufferevent_private *bufev_p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_p = BEV_UPCAST(bufev);
if (cbinfo->n_added &&
(bufev->enabled & EV_WRITE) &&
bufferevent_readcb(evutil_socket_t fd, short event, void *arg)
{
struct bufferevent *bufev = arg;
- struct bufferevent_private *bufev_p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_p = BEV_UPCAST(bufev);
struct evbuffer *input;
int res = 0;
short what = BEV_EVENT_READING;
bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
{
struct bufferevent *bufev = arg;
- struct bufferevent_private *bufev_p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_p = BEV_UPCAST(bufev);
int res = 0;
short what = BEV_EVENT_WRITING;
int connected = 0;
bufferevent_socket_connect(struct bufferevent *bev,
const struct sockaddr *sa, int socklen)
{
- struct bufferevent_private *bufev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_p = BEV_UPCAST(bev);
evutil_socket_t fd;
int r = 0;
void *arg)
{
struct bufferevent *bev = arg;
- struct bufferevent_private *bev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
+ struct bufferevent_private *bev_p = BEV_UPCAST(bev);
int r;
BEV_LOCK(bev);
{
char portbuf[10];
struct evutil_addrinfo hint;
- struct bufferevent_private *bev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
+ struct bufferevent_private *bev_p = BEV_UPCAST(bev);
if (family != AF_INET && family != AF_INET6 && family != AF_UNSPEC)
return -1;
bufferevent_socket_get_dns_error(struct bufferevent *bev)
{
int rv;
- struct bufferevent_private *bev_p =
- EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
+ struct bufferevent_private *bev_p = BEV_UPCAST(bev);
BEV_LOCK(bev);
rv = bev_p->dns_error;
static int
be_socket_disable(struct bufferevent *bufev, short event)
{
- struct bufferevent_private *bufev_p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_p = BEV_UPCAST(bufev);
if (event & EV_READ) {
if (event_del(&bufev->ev_read) == -1)
return -1;
static void
be_socket_destruct(struct bufferevent *bufev)
{
- struct bufferevent_private *bufev_p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_p = BEV_UPCAST(bufev);
evutil_socket_t fd;
EVUTIL_ASSERT(BEV_IS_SOCKET(bufev));
static void
be_socket_setfd(struct bufferevent *bufev, evutil_socket_t fd)
{
- struct bufferevent_private *bufev_p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_p = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
EVUTIL_ASSERT(BEV_IS_SOCKET(bufev));
bufferevent_priority_set(struct bufferevent *bufev, int priority)
{
int r = -1;
- struct bufferevent_private *bufev_p =
- EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+ struct bufferevent_private *bufev_p = BEV_UPCAST(bufev);
BEV_LOCK(bufev);
if (!BEV_IS_SOCKET(bufev))