#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <assert.h>
#include "event2/util.h"
#include "event-config.h"
{
size_t size;
- assert(new_size >= op->readset_in->fd_count &&
+ EVUTIL_ASSERT(new_size >= op->readset_in->fd_count &&
new_size >= op->writeset_in->fd_count);
- assert(new_size >= 1);
+ EVUTIL_ASSERT(new_size >= 1);
size = FD_SET_ALLOC_SIZE(new_size);
if (!(op->readset_in = mm_realloc(op->readset_in, size)))
#include <sys/sendfile.h>
#endif
-#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
void
_evbuffer_chain_pin(struct evbuffer_chain *chain, unsigned flag)
{
- assert((chain->flags & flag) == 0);
+ EVUTIL_ASSERT((chain->flags & flag) == 0);
chain->flags |= flag;
}
void
_evbuffer_chain_unpin(struct evbuffer_chain *chain, unsigned flag)
{
- assert((chain->flags & flag) != 0);
+ EVUTIL_ASSERT((chain->flags & flag) != 0);
chain->flags &= ~flag;
if (chain->flags & EVBUFFER_DANGLING)
evbuffer_chain_free(chain);
/* Make sure that none of the chains we need to copy from is pinned. */
remaining = size - chain->off;
- assert(remaining >= 0);
+ EVUTIL_ASSERT(remaining >= 0);
for (tmp=chain->next; tmp; tmp=tmp->next) {
if (CHAIN_PINNED(tmp))
goto done;
static void
evbuffer_chain_align(struct evbuffer_chain *chain)
{
- assert(!(chain->flags & EVBUFFER_IMMUTABLE));
- assert(!(chain->flags & EVBUFFER_MEM_PINNED_ANY));
+ EVUTIL_ASSERT(!(chain->flags & EVBUFFER_IMMUTABLE));
+ EVUTIL_ASSERT(!(chain->flags & EVBUFFER_MEM_PINNED_ANY));
memmove(chain->buffer, chain->buffer + chain->misalign, chain->off);
chain->misalign = 0;
}
struct evbuffer_chain *chain = buf->last;
size_t used = chain->misalign + chain->off;
buffer = (char *)chain->buffer + chain->misalign + chain->off;
- assert(chain->buffer_len >= used);
+ EVUTIL_ASSERT(chain->buffer_len >= used);
space = chain->buffer_len - used;
#ifndef va_copy
#include <winsock2.h>
#include <windows.h>
-#include <assert.h>
#include <stdio.h>
#define MAX_WSABUFS 16
struct evbuffer_chain *chain = bo->first_pinned;
for (i = 0; i < bo->n_buffers; ++i) {
- assert(chain);
+ EVUTIL_ASSERT(chain);
_evbuffer_chain_unpin(chain, flag);
chain = chain->next;
}
}
if (evbuffer_commit_space(evbuf, iov, n_vec) < 0)
- assert(0); /* XXXX fail nicer. */
+ EVUTIL_ASSERT(0); /* XXXX fail nicer. */
pin_release(eo, EVBUFFER_MEM_PINNED_R);
_evbuffer_chain_pin(chain, EVBUFFER_MEM_PINNED_R);
++npin;
}
- assert(npin == nvecs);
+ EVUTIL_ASSERT(npin == nvecs);
_evbuffer_incref(buf);
if (WSARecv(buf_o->fd, buf_o->read_info.buffers, nvecs, &bytesRead, &flags, &buf_o->read_info.event_overlapped.overlapped, NULL)) {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
#ifdef _EVENT_HAVE_STDARG_H
#include <stdarg.h>
#endif
if (bev->be_ops != &bufferevent_ops_async)
return NULL;
bev_a = EVUTIL_UPCAST(bev, struct bufferevent_async, bev.bev);
- assert(bev_a->bev.bev.be_ops == &bufferevent_ops_async);
+ EVUTIL_ASSERT(bev_a->bev.bev.be_ops == &bufferevent_ops_async);
return bev_a;
}
/* XXXX doesn't respect low-water mark very well. */
if (evbuffer_launch_write(b->bev.bev.output, -1)) {
- assert(0);/* XXX act sensibly. */
+ EVUTIL_ASSERT(0);/* XXX act sensibly. */
} else {
b->write_in_progress = 1;
}
}
if (evbuffer_launch_read(b->bev.bev.input, at_most)) {
- assert(0);
+ EVUTIL_ASSERT(0);
} else {
b->read_in_progress = 1;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
#ifdef _EVENT_HAVE_STDARG_H
#include <stdarg.h>
#endif
return NULL;
bev_f = (void*)( ((char*)bev) -
evutil_offsetof(struct bufferevent_filtered, bev.bev));
- assert(bev_f->bev.bev.be_ops == &bufferevent_ops_filter);
+ EVUTIL_ASSERT(bev_f->bev.bev.be_ops == &bufferevent_ops_filter);
return bev_f;
}
be_filter_destruct(struct bufferevent *bev)
{
struct bufferevent_filtered *bevf = upcast(bev);
- assert(bevf);
+ EVUTIL_ASSERT(bevf);
if (bevf->free_context)
bevf->free_context(bevf->context);
{
struct bufferevent_filtered *bevf = upcast(bufev);
int processed_any = 0;
- assert(bevf);
+ EVUTIL_ASSERT(bevf);
_bufferevent_incref_and_lock(bufev);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
#ifdef _EVENT_HAVE_STDARG_H
#include <stdarg.h>
#endif
inlen = bufev->wm_write.high - outlen;
}
- assert(inlen > 0);
+ EVUTIL_ASSERT(inlen > 0);
evbuffer_add(output, in, inlen);
return inlen;
}
return NULL;
bev_o = (void*)( ((char*)bev) -
evutil_offsetof(struct bufferevent_openssl, bev.bev));
- assert(bev_o->bev.bev.be_ops == &bufferevent_ops_openssl);
+ EVUTIL_ASSERT(bev_o->bev.bev.be_ops == &bufferevent_ops_openssl);
return bev_o;
}
switch (bev_ssl->state) {
default:
case BUFFEREVENT_SSL_OPEN:
- assert(0);
+ EVUTIL_ASSERT(0);
break;
case BUFFEREVENT_SSL_CONNECTING:
case BUFFEREVENT_SSL_ACCEPTING:
*/
#include <sys/types.h>
-#include <assert.h>
#ifdef WIN32
#include <winsock2.h>
if (bev->be_ops != &bufferevent_ops_pair)
return NULL;
bev_p = EVUTIL_UPCAST(bev, struct bufferevent_pair, bev.bev);
- assert(bev_p->bev.bev.be_ops == &bufferevent_ops_pair);
+ EVUTIL_ASSERT(bev_p->bev.bev.be_ops == &bufferevent_ops_pair);
return bev_p;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
#ifdef _EVENT_HAVE_STDARG_H
#include <stdarg.h>
#endif
struct bufferevent_private *bufev_p =
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
evutil_socket_t fd;
- assert(bufev->be_ops == &bufferevent_ops_socket);
+ EVUTIL_ASSERT(bufev->be_ops == &bufferevent_ops_socket);
fd = event_get_fd(&bufev->ev_read);
be_socket_setfd(struct bufferevent *bufev, evutil_socket_t fd)
{
BEV_LOCK(bufev);
- assert(bufev->be_ops == &bufferevent_ops_socket);
+ EVUTIL_ASSERT(bufev->be_ops == &bufferevent_ops_socket);
event_del(&bufev->ev_read);
event_del(&bufev->ev_write);
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
-#include <assert.h>
#include "event2/event.h"
#include "event2/event_struct.h"
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <assert.h>
#ifdef _EVENT_HAVE_FCNTL_H
#include <fcntl.h>
#endif
}
event_debug(("%s: epoll_wait reports %d", __func__, res));
- assert(res <= epollop->nevents);
+ EVUTIL_ASSERT(res <= epollop->nevents);
for (i = 0; i < res; i++) {
int what = events[i].events;
/** Assert that somebody (hopefully us) is holding the lock on an evbuffer */
#define ASSERT_EVBUFFER_LOCKED(buffer) \
do { \
- assert((buffer)->lock_count > 0); \
+ EVUTIL_ASSERT((buffer)->lock_count > 0); \
} while (0)
/** Assert that nobody is holding the lock on an evbuffer */
#define ASSERT_EVBUFFER_UNLOCKED(buffer) \
do { \
- assert((buffer)->lock_count == 0); \
+ EVUTIL_ASSERT((buffer)->lock_count == 0); \
} while (0)
#define _EVBUFFER_INCREMENT_LOCK_COUNT(buffer) \
do { \
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <assert.h>
#ifdef _EVENT_HAVE_UNISTD_H
#include <unistd.h>
#endif
} while (0)
#define EVDNS_UNLOCK(base) \
do { \
- assert((base)->lock_count > 0); \
+ EVUTIL_ASSERT((base)->lock_count > 0); \
--(base)->lock_count; \
if ((base)->lock) { \
EVLOCK_UNLOCK((base)->lock, EVTHREAD_WRITE); \
} \
} while (0)
-#define ASSERT_LOCKED(base) assert((base)->lock_count > 0)
+#define ASSERT_LOCKED(base) EVUTIL_ASSERT((base)->lock_count > 0)
#endif
#define CLOSE_SOCKET(s) EVUTIL_CLOSESOCKET(s)
log(EVDNS_LOG_WARN, "Nameserver %s has failed: %s",
debug_ntop((struct sockaddr*)&ns->address), msg);
base->global_good_nameservers--;
- assert(base->global_good_nameservers >= 0);
+ EVUTIL_ASSERT(base->global_good_nameservers >= 0);
if (base->global_good_nameservers == 0) {
log(EVDNS_LOG_WARN, "All nameservers have failed");
}
base->global_requests_waiting) {
struct evdns_request *req;
/* move a request from the waiting queue to the inflight queue */
- assert(base->req_waiting_head);
+ EVUTIL_ASSERT(base->req_waiting_head);
req = base->req_waiting_head;
evdns_request_remove(req, &base->req_waiting_head);
cb->user_callback(cb->err, 0, 0, 0, NULL, user_pointer);
break;
default:
- assert(0);
+ EVUTIL_ASSERT(0);
}
mm_free(cb);
req = request_find_from_trans_id(base, trans_id);
if (!req) return -1;
- assert(req->base == base);
+ EVUTIL_ASSERT(req->base == base);
memset(&reply, 0, sizeof(reply));
/* all the nameservers seem to be down */
/* so we just return this one and hope for the */
/* best */
- assert(base->global_good_nameservers == 0);
+ EVUTIL_ASSERT(base->global_good_nameservers == 0);
picked = base->server_head;
base->server_head = base->server_head->next;
return picked;
return NULL;
memset(port, 0, sizeof(struct evdns_server_port));
- assert(!is_tcp); /* TCP sockets not yet implemented */
+ EVUTIL_ASSERT(!is_tcp); /* TCP sockets not yet implemented */
port->socket = socket;
port->refcnt = 1;
port->choked = 0;
{
u32 a;
char buf[32];
- assert(in || inaddr_name);
- assert(!(in && inaddr_name));
+ EVUTIL_ASSERT(in || inaddr_name);
+ EVUTIL_ASSERT(!(in && inaddr_name));
if (in) {
a = ntohl(in->s_addr);
evutil_snprintf(buf, sizeof(buf), "%d.%d.%d.%d.in-addr.arpa",
static void
server_port_free(struct evdns_server_port *port)
{
- assert(port);
- assert(!port->refcnt);
- assert(!port->pending_replies);
+ EVUTIL_ASSERT(port);
+ EVUTIL_ASSERT(!port->refcnt);
+ EVUTIL_ASSERT(!port->pending_replies);
if (port->socket > 0) {
CLOSE_SOCKET(port->socket);
port->socket = -1;
{
struct evdns_request *ptr;
int found = 0;
- assert(*head != NULL);
+ EVUTIL_ASSERT(*head != NULL);
ptr = *head;
do {
}
ptr = ptr->next;
} while (ptr != *head);
- assert(found);
+ EVUTIL_ASSERT(found);
- assert(req->next);
+ EVUTIL_ASSERT(req->next);
}
#endif
char buf[32];
struct evdns_request *req;
u32 a;
- assert(in);
+ EVUTIL_ASSERT(in);
a = ntohl(in->s_addr);
evutil_snprintf(buf, sizeof(buf), "%d.%d.%d.%d.in-addr.arpa",
(int)(u8)((a )&0xff),
char *cp;
struct evdns_request *req;
int i;
- assert(in);
+ EVUTIL_ASSERT(in);
cp = buf;
for (i=15; i >= 0; --i) {
u8 byte = in->s6_addr[i];
*cp++ = "0123456789abcdef"[byte >> 4];
*cp++ = '.';
}
- assert(cp + strlen("ip6.arpa") < buf+sizeof(buf));
+ EVUTIL_ASSERT(cp + strlen("ip6.arpa") < buf+sizeof(buf));
memcpy(cp, "ip6.arpa", strlen("ip6.arpa")+1);
log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
EVDNS_LOCK(base);
static struct evdns_request *
search_request_new(struct evdns_base *base, int type, const char *const name, int flags, evdns_callback_type user_callback, void *user_arg) {
ASSERT_LOCKED(base);
- assert(type == TYPE_A || type == TYPE_AAAA);
+ EVUTIL_ASSERT(type == TYPE_A || type == TYPE_AAAA);
if ( ((flags & DNS_QUERY_NO_SEARCH) == 0) &&
base->global_search_state &&
base->global_search_state->num_domains) {
if (maxinflight < 1)
maxinflight = 1;
n_heads = (maxinflight+4) / 5;
- assert(n_heads > 0);
+ EVUTIL_ASSERT(n_heads > 0);
new_heads = mm_malloc(n_heads * sizeof(struct evdns_request*));
if (!new_heads)
return (-1);
n += r;
if (n == st.st_size)
break;
- assert(n < st.st_size);
+ EVUTIL_ASSERT(n < st.st_size);
}
if (r < 0) { err = 5; goto out2; }
resolv[n] = 0; /* we malloced an extra byte; this should be fine. */
}
}
- assert(fixed);
+ EVUTIL_ASSERT(fixed);
added_any = 0;
ns = &(fixed->DnsServerList);
while (ns) {
#include <errno.h>
#include <signal.h>
#include <string.h>
-#include <assert.h>
#include <time.h>
#include "event2/event.h"
current_base = NULL;
/* XXX(niels) - check for internal events first */
- assert(base);
+ EVUTIL_ASSERT(base);
/* threading fds if we have them */
if (base->th_notify_fd[0] != -1) {
base->evsel->dealloc(base);
for (i = 0; i < base->nactivequeues; ++i)
- assert(TAILQ_EMPTY(base->activequeues[i]));
+ EVUTIL_ASSERT(TAILQ_EMPTY(base->activequeues[i]));
- assert(min_heap_empty(&base->timeheap));
+ EVUTIL_ASSERT(min_heap_empty(&base->timeheap));
min_heap_dtor(&base->timeheap);
for (i = 0; i < base->nactivequeues; ++i)
mm_free(base->activequeues[i]);
mm_free(base->activequeues);
- assert(TAILQ_EMPTY(&base->eventqueue));
+ EVUTIL_ASSERT(TAILQ_EMPTY(&base->eventqueue));
evmap_io_clear(&base->io);
evmap_signal_clear(&base->sigmap);
struct event *ev;
int count = 0;
- assert(activeq != NULL);
+ EVUTIL_ASSERT(activeq != NULL);
for (ev = TAILQ_FIRST(activeq); ev; ev = TAILQ_FIRST(activeq)) {
if (ev->ev_events & EV_PERSIST)
const char *
event_base_get_method(struct event_base *base)
{
- assert(base);
+ EVUTIL_ASSERT(base);
return (base->evsel->name);
}
{
event_set(ev, fd, events, cb, arg);
if (base != NULL)
- assert(event_base_set(base, ev) == 0);
+ EVUTIL_ASSERT(event_base_set(base, ev) == 0);
}
struct event *
tv ? "EV_TIMEOUT " : " ",
ev->ev_callback));
- assert(!(ev->ev_flags & ~EVLIST_ALL));
+ EVUTIL_ASSERT(!(ev->ev_flags & ~EVLIST_ALL));
/*
* prepare for timeout insertion further below, if we get a
if (need_cur_lock)
EVBASE_ACQUIRE_LOCK(base, EVTHREAD_WRITE, current_event_lock);
- assert(!(ev->ev_flags & ~EVLIST_ALL));
+ EVUTIL_ASSERT(!(ev->ev_flags & ~EVLIST_ALL));
/* See if we are just active executing this event in a loop */
if (ev->ev_events & EV_SIGNAL) {
evutil_timersub(&ev->ev_timeout, &now, tv);
- assert(tv->tv_sec >= 0);
- assert(tv->tv_usec >= 0);
+ EVUTIL_ASSERT(tv->tv_sec >= 0);
+ EVUTIL_ASSERT(tv->tv_usec >= 0);
event_debug(("timeout_next: in %d seconds", (int)tv->tv_sec));
out:
#include <errno.h>
#include <signal.h>
#include <string.h>
-#include <assert.h>
#include <time.h>
#include "event-internal.h"
}, \
{ \
_ent = mm_calloc(1,sizeof(struct event_map_entry)+fdinfo_len); \
- assert(_ent); \
+ EVUTIL_ASSERT(_ent); \
_ent->fd = slot; \
(ctor)(&_ent->ent.type); \
_HT_FOI_INSERT(map_node, map, &_key, _ent, ptr) \
#define GET_SIGNAL_SLOT_AND_CTOR(x, map, slot, type, ctor, fdinfo_len) \
do { \
if ((map)->entries[slot] == NULL) { \
- assert(ctor != NULL); \
+ EVUTIL_ASSERT(ctor != NULL); \
(map)->entries[slot] = \
mm_calloc(1,sizeof(struct type)+fdinfo_len); \
- assert((map)->entries[slot] != NULL); \
+ EVUTIL_ASSERT((map)->entries[slot] != NULL); \
(ctor)((struct type *)(map)->entries[slot]); \
} \
(x) = (struct type *)((map)->entries[slot]); \
int nread, nwrite, retval = 0;
short res = 0, old = 0;
- assert(fd == ev->ev_fd); /*XXX(nickm) always true? */
+ EVUTIL_ASSERT(fd == ev->ev_fd); /*XXX(nickm) always true? */
/*XXX(nickm) Should we assert that ev is not already inserted, or should
* we make this function idempotent? */
if (fd < 0)
return 0;
- assert(fd == ev->ev_fd); /*XXX(nickm) always true? */
+ EVUTIL_ASSERT(fd == ev->ev_fd); /*XXX(nickm) always true? */
/*XXX(nickm) Should we assert that ev is not already inserted, or should
* we make this function idempotent? */
if (ev->ev_events & EV_READ) {
if (--nread == 0)
res |= EV_READ;
- assert(nread >= 0);
+ EVUTIL_ASSERT(nread >= 0);
}
if (ev->ev_events & EV_WRITE) {
if (--nwrite == 0)
res |= EV_WRITE;
- assert(nwrite >= 0);
+ EVUTIL_ASSERT(nwrite >= 0);
}
if (res) {
struct event *ev;
#ifndef EVMAP_USE_HT
- assert(fd < io->nentries);
+ EVUTIL_ASSERT(fd < io->nentries);
#endif
GET_IO_SLOT(ctx, io, fd, evmap_io);
- assert(ctx);
+ EVUTIL_ASSERT(ctx);
TAILQ_FOREACH(ev, &ctx->events, ev_io_next) {
if (ev->ev_events & events)
event_active(ev, ev->ev_events & events, 1);
struct evmap_signal *ctx;
struct event *ev;
- assert(sig < map->nentries);
+ EVUTIL_ASSERT(sig < map->nentries);
GET_SIGNAL_SLOT(ctx, map, sig, evmap_signal);
TAILQ_FOREACH(ev, &ctx->events, ev_signal_next)
#endif
#include <sys/time.h>
-#include <assert.h>
#include <sys/queue.h>
#include <errno.h>
#include <poll.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
-#ifdef CHECK_INVARIANTS
-#include <assert.h>
-#endif
#include "event-internal.h"
#include "log-internal.h"
static void
check_evportop(struct evport_data *evpd)
{
- assert(evpd);
- assert(evpd->ed_nevents > 0);
- assert(evpd->ed_port > 0);
- assert(evpd->ed_fds > 0);
+ EVUTIL_ASSERT(evpd);
+ EVUTIL_ASSERT(evpd->ed_nevents > 0);
+ EVUTIL_ASSERT(evpd->ed_port > 0);
+ EVUTIL_ASSERT(evpd->ed_fds > 0);
}
/*
* but since we're not using port_alert either, we can assume
* PORT_SOURCE_FD.
*/
- assert(pevt->portev_source == PORT_SOURCE_FD);
- assert(pevt->portev_user == NULL);
+ EVUTIL_ASSERT(pevt->portev_source == PORT_SOURCE_FD);
+ EVUTIL_ASSERT(pevt->portev_user == NULL);
}
#else
struct fd_info *tmp;
int oldsize = epdp->ed_nevents;
int newsize = factor * oldsize;
- assert(factor > 1);
+ EVUTIL_ASSERT(factor > 1);
check_evportop(epdp);
if (pevt->portev_events & POLLOUT)
res |= EV_WRITE;
- assert(epdp->ed_nevents > fd);
+ EVUTIL_ASSERT(epdp->ed_nevents > fd);
fdi = &(epdp->ed_fds[fd]);
evmap_io_active(base, fd, res);
#include <errno.h>
#include <signal.h>
#include <string.h>
-#include <assert.h>
#include <sys/queue.h>
struct evrpc_hook_ctx *pause;
while ((rpc = TAILQ_FIRST(&base->registered_rpcs)) != NULL) {
- assert(evrpc_unregister_rpc(base, rpc->uri));
+ EVUTIL_ASSERT(evrpc_unregister_rpc(base, rpc->uri));
}
while ((pause = TAILQ_FIRST(&base->paused_requests)) != NULL) {
TAILQ_REMOVE(&base->paused_requests, pause, next);
mm_free(pause);
}
while ((hook = TAILQ_FIRST(&base->input_hooks)) != NULL) {
- assert(evrpc_remove_hook(base, EVRPC_INPUT, hook));
+ EVUTIL_ASSERT(evrpc_remove_hook(base, EVRPC_INPUT, hook));
}
while ((hook = TAILQ_FIRST(&base->output_hooks)) != NULL) {
- assert(evrpc_remove_hook(base, EVRPC_OUTPUT, hook));
+ EVUTIL_ASSERT(evrpc_remove_hook(base, EVRPC_OUTPUT, hook));
}
mm_free(base);
}
head = &base->out_hooks;
break;
default:
- assert(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT);
+ EVUTIL_ASSERT(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT);
}
hook = mm_calloc(1, sizeof(struct evrpc_hook));
- assert(hook != NULL);
+ EVUTIL_ASSERT(hook != NULL);
hook->process = cb;
hook->process_arg = cb_arg;
head = &base->out_hooks;
break;
default:
- assert(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT);
+ EVUTIL_ASSERT(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT);
}
return (evrpc_remove_hook_internal(head, handle));
registered_uri = evrpc_construct_uri(name);
/* remove the http server callback */
- assert(evhttp_del_cb(base->http_server, registered_uri) == 0);
+ EVUTIL_ASSERT(evhttp_del_cb(base->http_server, registered_uri) == 0);
mm_free(registered_uri);
return (0);
case EVRPC_CONTINUE:
break;
default:
- assert(hook_res == EVRPC_TERMINATE ||
+ EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE ||
hook_res == EVRPC_CONTINUE ||
hook_res == EVRPC_PAUSE);
}
evrpc_reqstate_free(struct evrpc_req_generic* rpc_state)
{
struct evrpc *rpc;
- assert(rpc_state != NULL);
+ EVUTIL_ASSERT(rpc_state != NULL);
rpc = rpc_state->rpc;
/* clean up all memory */
case EVRPC_CONTINUE:
break;
default:
- assert(hook_res == EVRPC_TERMINATE ||
+ EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE ||
hook_res == EVRPC_CONTINUE ||
hook_res == EVRPC_PAUSE);
}
}
while ((hook = TAILQ_FIRST(&pool->input_hooks)) != NULL) {
- assert(evrpc_remove_hook(pool, EVRPC_INPUT, hook));
+ EVUTIL_ASSERT(evrpc_remove_hook(pool, EVRPC_INPUT, hook));
}
while ((hook = TAILQ_FIRST(&pool->output_hooks)) != NULL) {
- assert(evrpc_remove_hook(pool, EVRPC_OUTPUT, hook));
+ EVUTIL_ASSERT(evrpc_remove_hook(pool, EVRPC_OUTPUT, hook));
}
mm_free(pool);
evrpc_pool_add_connection(struct evrpc_pool *pool,
struct evhttp_connection *connection)
{
- assert(connection->http_server == NULL);
+ EVUTIL_ASSERT(connection->http_server == NULL);
TAILQ_INSERT_TAIL(&pool->connections, connection, next);
/*
/* we can just continue */
break;
default:
- assert(hook_res == EVRPC_TERMINATE ||
+ EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE ||
hook_res == EVRPC_CONTINUE ||
hook_res == EVRPC_PAUSE);
}
evtimer_assign(&ctx->ev_timeout, pool->base, evrpc_request_timeout, ctx);
/* we better have some available connections on the pool */
- assert(TAILQ_FIRST(&pool->connections) != NULL);
+ EVUTIL_ASSERT(TAILQ_FIRST(&pool->connections) != NULL);
/*
* if no connection is available, we queue the request on the pool,
evrpc_reply_done_closure);
return;
default:
- assert(hook_res == EVRPC_TERMINATE ||
+ EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE ||
hook_res == EVRPC_CONTINUE ||
hook_res == EVRPC_PAUSE);
}
{
struct evrpc_request_wrapper *ctx = arg;
struct evhttp_connection *evcon = ctx->evcon;
- assert(evcon != NULL);
+ EVUTIL_ASSERT(evcon != NULL);
evhttp_connection_fail(evcon, EVCON_HTTP_TIMEOUT);
}
evrpc_meta_data_free(struct evrpc_meta_list *meta_data)
{
struct evrpc_meta *entry;
- assert(meta_data != NULL);
+ EVUTIL_ASSERT(meta_data != NULL);
while ((entry = TAILQ_FIRST(meta_data)) != NULL) {
TAILQ_REMOVE(meta_data, entry, next);
{
struct evrpc_hook_meta *ctx;
ctx = mm_malloc(sizeof(struct evrpc_hook_meta));
- assert(ctx != NULL);
+ EVUTIL_ASSERT(ctx != NULL);
TAILQ_INIT(&ctx->meta_data);
ctx->evcon = NULL;
if ((store = req->hook_meta) == NULL)
store = req->hook_meta = evrpc_hook_meta_new();
- assert((meta = mm_malloc(sizeof(struct evrpc_meta))) != NULL);
- assert((meta->key = mm_strdup(key)) != NULL);
+ EVUTIL_ASSERT((meta = mm_malloc(sizeof(struct evrpc_meta))) != NULL);
+ EVUTIL_ASSERT((meta->key = mm_strdup(key)) != NULL);
meta->data_size = data_size;
- assert((meta->data = mm_malloc(data_size)) != NULL);
+ EVUTIL_ASSERT((meta->data = mm_malloc(data_size)) != NULL);
memcpy(meta->data, data, data_size);
TAILQ_INSERT_TAIL(&store->meta_data, meta, next);
#include <winsock2.h>
#endif
-#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
strsep(char **s, const char *del)
{
char *d, *tok;
- assert(strlen(del) == 1);
+ EVUTIL_ASSERT(strlen(del) == 1);
if (!s || !*s)
return NULL;
tok = *s;
struct evhttp_request* req = TAILQ_FIRST(&evcon->requests);
void (*cb)(struct evhttp_request *, void *);
void *cb_arg;
- assert(req != NULL);
+ EVUTIL_ASSERT(req != NULL);
bufferevent_disable(evcon->bufev, EV_READ|EV_WRITE);
{
/* This is after writing the request to the server */
struct evhttp_request *req = TAILQ_FIRST(&evcon->requests);
- assert(req != NULL);
+ EVUTIL_ASSERT(req != NULL);
- assert(evcon->state == EVCON_WRITING);
+ EVUTIL_ASSERT(evcon->state == EVCON_WRITING);
/* We are done writing our header and are now expecting the response */
req->kind = EVHTTP_RESPONSE;
evhttp_connection_set_local_address(struct evhttp_connection *evcon,
const char *address)
{
- assert(evcon->state == EVCON_DISCONNECTED);
+ EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED);
if (evcon->bind_address)
mm_free(evcon->bind_address);
if ((evcon->bind_address = mm_strdup(address)) == NULL)
evhttp_connection_set_local_port(struct evhttp_connection *evcon,
ev_uint16_t port)
{
- assert(evcon->state == EVCON_DISCONNECTED);
+ EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED);
evcon->bind_port = port;
}
evhttp_connection_stop_detectclose(evcon);
/* we assume that the connection is connected already */
- assert(evcon->state == EVCON_IDLE);
+ EVUTIL_ASSERT(evcon->state == EVCON_IDLE);
evcon->state = EVCON_WRITING;
*/
if (evcon->flags & EVHTTP_CON_CLOSEDETECT) {
evcon->flags &= ~EVHTTP_CON_CLOSEDETECT;
- assert(evcon->http_server == NULL);
+ EVUTIL_ASSERT(evcon->http_server == NULL);
/* For connections from the client, we just
* reset the connection so that it becomes
* disconnected.
*/
- assert(evcon->state == EVCON_IDLE);
+ EVUTIL_ASSERT(evcon->state == EVCON_IDLE);
evhttp_connection_reset(evcon);
return;
}
evhttp_connection_set_base(struct evhttp_connection *evcon,
struct event_base *base)
{
- assert(evcon->base == NULL);
- assert(evcon->state == EVCON_DISCONNECTED);
+ EVUTIL_ASSERT(evcon->base == NULL);
+ EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED);
evcon->base = base;
bufferevent_base_set(base, evcon->bufev);
}
evhttp_connection_reset(evcon);
- assert(!(evcon->flags & EVHTTP_CON_INCOMING));
+ EVUTIL_ASSERT(!(evcon->flags & EVHTTP_CON_INCOMING));
evcon->flags |= EVHTTP_CON_OUTGOING;
evcon->fd = bind_socket(
req->minor = 1;
}
- assert(req->evcon == NULL);
+ EVUTIL_ASSERT(req->evcon == NULL);
req->evcon = evcon;
- assert(!(req->flags & EVHTTP_REQ_OWN_CONNECTION));
+ EVUTIL_ASSERT(!(req->flags & EVHTTP_REQ_OWN_CONNECTION));
TAILQ_INSERT_TAIL(&evcon->requests, req, next);
evhttp_is_connection_close(req->flags, req->input_headers) ||
evhttp_is_connection_close(req->flags, req->output_headers);
- assert(req->flags & EVHTTP_REQ_OWN_CONNECTION);
+ EVUTIL_ASSERT(req->flags & EVHTTP_REQ_OWN_CONNECTION);
evhttp_request_free(req);
if (need_close) {
{
struct evhttp_connection *evcon = req->evcon;
- assert(TAILQ_FIRST(&evcon->requests) == req);
+ EVUTIL_ASSERT(TAILQ_FIRST(&evcon->requests) == req);
/* xxx: not sure if we really should expose the data buffer this way */
if (databuf != NULL)
return (aitop);
#else
- assert(0);
+ EVUTIL_ASSERT(0);
return NULL; /* XXXXX Use gethostbyname, if this function is ever used. */
#endif
}
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <assert.h>
#ifdef _EVENT_HAVE_INTTYPES_H
#include <inttypes.h>
#endif
struct timespec timeout = { 0, 0 };
(void)p;
- assert(nsignal >= 0 && nsignal < NSIG);
+ EVUTIL_ASSERT(nsignal >= 0 && nsignal < NSIG);
memset(&kev, 0, sizeof(kev));
kev.ident = nsignal;
struct timespec timeout = { 0, 0 };
(void)p;
- assert(nsignal >= 0 && nsignal < NSIG);
+ EVUTIL_ASSERT(nsignal >= 0 && nsignal < NSIG);
memset(&kev, 0, sizeof(kev));
kev.ident = nsignal;
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <assert.h>
#include "event-internal.h"
#include "evsignal-internal.h"
idx = pop->idxplus1_by_fd[i]-1;
if (idx < 0)
continue;
- assert(pop->event_set[idx].fd == i);
+ EVUTIL_ASSERT(pop->event_set[idx].fd == i);
}
for (i = 0; i < pop->nfds; ++i) {
struct pollfd *pfd = &pop->event_set[i];
- assert(pop->idxplus1_by_fd[pfd->fd] == i+1);
+ EVUTIL_ASSERT(pop->idxplus1_by_fd[pfd->fd] == i+1);
}
}
#else
struct pollidx *idx = _idx;
int i;
- assert((events & EV_SIGNAL) == 0);
+ EVUTIL_ASSERT((events & EV_SIGNAL) == 0);
if (!(events & (EV_READ|EV_WRITE)))
return (0);
struct pollidx *idx = _idx;
int i;
- assert((events & EV_SIGNAL) == 0);
+ EVUTIL_ASSERT((events & EV_SIGNAL) == 0);
if (!(events & (EV_READ|EV_WRITE)))
return (0);
memcpy(&pop->event_set[i], &pop->event_set[pop->nfds],
sizeof(struct pollfd));
idx = evmap_io_get_fdinfo(&base->io, pop->event_set[i].fd);
- assert(idx);
- assert(idx->idxplus1 == pop->nfds + 1);
+ EVUTIL_ASSERT(idx);
+ EVUTIL_ASSERT(idx->idxplus1 == pop->nfds + 1);
idx->idxplus1 = i + 1;
}
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <assert.h>
#include "event-internal.h"
#include "evsignal-internal.h"
struct selectop *sop = base->evbase;
(void) p;
- assert((events & EV_SIGNAL) == 0);
+ EVUTIL_ASSERT((events & EV_SIGNAL) == 0);
check_selectop(sop);
/*
* Keep track of the highest fd, so that we can calculate the size
struct selectop *sop = base->evbase;
(void)p;
- assert((events & EV_SIGNAL) == 0);
+ EVUTIL_ASSERT((events & EV_SIGNAL) == 0);
check_selectop(sop);
if (sop->event_fds < fd) {
#ifdef _EVENT_HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#include <assert.h>
#include "event2/event.h"
#include "event2/event_struct.h"
struct evsig_info *sig = &base->sig;
(void)p;
- assert(evsignal >= 0 && evsignal < NSIG);
+ EVUTIL_ASSERT(evsignal >= 0 && evsignal < NSIG);
event_debug(("%s: %d: changing signal handler", __func__, evsignal));
if (_evsig_set_handler(base, evsignal, evsig_handler) == -1)
static int
evsig_del(struct event_base *base, int evsignal, short old, short events, void *p)
{
- assert(evsignal >= 0 && evsignal < NSIG);
+ EVUTIL_ASSERT(evsignal >= 0 && evsignal < NSIG);
event_debug(("%s: %d: restoring signal handler", __func__, evsignal));