mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-17 08:17:42 -04:00
Use EVUTIL_ASSERT() consistently instead of assert.
svn:r1464
This commit is contained in:
parent
37c3456d70
commit
2e36dbe1a6
@ -35,7 +35,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "event2/util.h"
|
||||
#include "event-config.h"
|
||||
@ -101,9 +100,9 @@ realloc_fd_sets(struct win32op *op, size_t new_size)
|
||||
{
|
||||
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)))
|
||||
|
13
buffer.c
13
buffer.c
@ -66,7 +66,6 @@
|
||||
#include <sys/sendfile.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -245,14 +244,14 @@ evbuffer_chain_insert(struct evbuffer *buf, struct evbuffer_chain *chain)
|
||||
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);
|
||||
@ -895,7 +894,7 @@ evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size)
|
||||
|
||||
/* 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;
|
||||
@ -1347,8 +1346,8 @@ 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;
|
||||
}
|
||||
@ -2112,7 +2111,7 @@ evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap)
|
||||
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
|
||||
|
@ -44,7 +44,6 @@
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_WSABUFS 16
|
||||
@ -104,7 +103,7 @@ pin_release(struct event_overlapped *eo, unsigned flag)
|
||||
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;
|
||||
}
|
||||
@ -137,7 +136,7 @@ read_completed(struct event_overlapped *eo, uintptr_t _, ev_ssize_t nBytes)
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -287,7 +286,7 @@ evbuffer_launch_read(struct evbuffer *buf, size_t at_most)
|
||||
_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)) {
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#ifdef _EVENT_HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
@ -90,7 +89,7 @@ upcast(struct bufferevent *bev)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -107,7 +106,7 @@ bev_async_consider_writing(struct bufferevent_async *b)
|
||||
|
||||
/* 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;
|
||||
}
|
||||
@ -136,7 +135,7 @@ bev_async_consider_reading(struct bufferevent_async *b)
|
||||
}
|
||||
|
||||
if (evbuffer_launch_read(b->bev.bev.input, at_most)) {
|
||||
assert(0);
|
||||
EVUTIL_ASSERT(0);
|
||||
} else {
|
||||
b->read_in_progress = 1;
|
||||
}
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#ifdef _EVENT_HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
@ -117,7 +116,7 @@ upcast(struct bufferevent *bev)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -211,7 +210,7 @@ static void
|
||||
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);
|
||||
|
||||
@ -437,7 +436,7 @@ be_filter_flush(struct bufferevent *bufev,
|
||||
{
|
||||
struct bufferevent_filtered *bevf = upcast(bufev);
|
||||
int processed_any = 0;
|
||||
assert(bevf);
|
||||
EVUTIL_ASSERT(bevf);
|
||||
|
||||
_bufferevent_incref_and_lock(bufev);
|
||||
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#ifdef _EVENT_HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
@ -182,7 +181,7 @@ bio_bufferevent_write(BIO *b, const char *in, int inlen)
|
||||
inlen = bufev->wm_write.high - outlen;
|
||||
}
|
||||
|
||||
assert(inlen > 0);
|
||||
EVUTIL_ASSERT(inlen > 0);
|
||||
evbuffer_add(output, in, inlen);
|
||||
return inlen;
|
||||
}
|
||||
@ -341,7 +340,7 @@ upcast(struct bufferevent *bev)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -786,7 +785,7 @@ do_handshake(struct bufferevent_openssl *bev_ssl)
|
||||
switch (bev_ssl->state) {
|
||||
default:
|
||||
case BUFFEREVENT_SSL_OPEN:
|
||||
assert(0);
|
||||
EVUTIL_ASSERT(0);
|
||||
break;
|
||||
case BUFFEREVENT_SSL_CONNECTING:
|
||||
case BUFFEREVENT_SSL_ACCEPTING:
|
||||
|
@ -25,7 +25,6 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
@ -60,7 +59,7 @@ upcast(struct bufferevent *bev)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#ifdef _EVENT_HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
@ -417,7 +416,7 @@ be_socket_destruct(struct bufferevent *bufev)
|
||||
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);
|
||||
|
||||
@ -449,7 +448,7 @@ static void
|
||||
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);
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "event2/event.h"
|
||||
#include "event2/event_struct.h"
|
||||
|
3
epoll.c
3
epoll.c
@ -44,7 +44,6 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#ifdef _EVENT_HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
@ -169,7 +168,7 @@ epoll_dispatch(struct event_base *base, struct timeval *tv)
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -200,12 +200,12 @@ struct evbuffer_chain_reference {
|
||||
/** 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 { \
|
||||
|
47
evdns.c
47
evdns.c
@ -91,7 +91,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#ifdef _EVENT_HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -405,13 +404,13 @@ static int strtoint(const char *const str);
|
||||
} 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)
|
||||
@ -555,7 +554,7 @@ nameserver_failed(struct nameserver *const ns, const char *msg) {
|
||||
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");
|
||||
}
|
||||
@ -688,7 +687,7 @@ evdns_requests_pump_waiting_queue(struct evdns_base *base) {
|
||||
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);
|
||||
|
||||
@ -750,7 +749,7 @@ reply_run_callback(struct deferred_cb *d, void *user_pointer)
|
||||
cb->user_callback(cb->err, 0, 0, 0, NULL, user_pointer);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
EVUTIL_ASSERT(0);
|
||||
}
|
||||
|
||||
mm_free(cb);
|
||||
@ -942,7 +941,7 @@ reply_parse(struct evdns_base *base, u8 *packet, int length) {
|
||||
|
||||
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));
|
||||
|
||||
@ -1292,7 +1291,7 @@ nameserver_pick(struct evdns_base *base) {
|
||||
/* 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;
|
||||
@ -1635,7 +1634,7 @@ evdns_add_server_port_with_base(struct event_base *base, evutil_socket_t socket,
|
||||
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;
|
||||
@ -1772,8 +1771,8 @@ evdns_server_request_add_ptr_reply(struct evdns_server_request *req, struct in_a
|
||||
{
|
||||
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",
|
||||
@ -2038,9 +2037,9 @@ server_request_free(struct server_request *req)
|
||||
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;
|
||||
@ -2511,7 +2510,7 @@ evdns_request_remove(struct evdns_request *req, struct evdns_request **head)
|
||||
{
|
||||
struct evdns_request *ptr;
|
||||
int found = 0;
|
||||
assert(*head != NULL);
|
||||
EVUTIL_ASSERT(*head != NULL);
|
||||
|
||||
ptr = *head;
|
||||
do {
|
||||
@ -2521,9 +2520,9 @@ evdns_request_remove(struct evdns_request *req, struct evdns_request **head)
|
||||
}
|
||||
ptr = ptr->next;
|
||||
} while (ptr != *head);
|
||||
assert(found);
|
||||
EVUTIL_ASSERT(found);
|
||||
|
||||
assert(req->next);
|
||||
EVUTIL_ASSERT(req->next);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2728,7 +2727,7 @@ evdns_base_resolve_reverse(struct evdns_base *base, const struct in_addr *in, in
|
||||
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),
|
||||
@ -2756,7 +2755,7 @@ evdns_base_resolve_reverse_ipv6(struct evdns_base *base, const struct in6_addr *
|
||||
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];
|
||||
@ -2765,7 +2764,7 @@ evdns_base_resolve_reverse_ipv6(struct evdns_base *base, const struct in6_addr *
|
||||
*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);
|
||||
@ -2960,7 +2959,7 @@ search_make_new(const struct search_state *const state, int n, const char *const
|
||||
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) {
|
||||
@ -3134,7 +3133,7 @@ evdns_base_set_max_requests_inflight(struct evdns_base *base, int maxinflight)
|
||||
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);
|
||||
@ -3321,7 +3320,7 @@ evdns_base_resolv_conf_parse_impl(struct evdns_base *base, int flags, const char
|
||||
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. */
|
||||
@ -3437,7 +3436,7 @@ load_nameservers_with_getnetworkparams(struct evdns_base *base)
|
||||
}
|
||||
}
|
||||
|
||||
assert(fixed);
|
||||
EVUTIL_ASSERT(fixed);
|
||||
added_any = 0;
|
||||
ns = &(fixed->DnsServerList);
|
||||
while (ns) {
|
||||
|
23
event.c
23
event.c
@ -58,7 +58,6 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "event2/event.h"
|
||||
@ -378,7 +377,7 @@ event_base_free(struct event_base *base)
|
||||
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) {
|
||||
@ -422,16 +421,16 @@ event_base_free(struct event_base *base)
|
||||
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);
|
||||
@ -681,7 +680,7 @@ event_process_active_single_queue(struct event_base *base,
|
||||
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)
|
||||
@ -800,7 +799,7 @@ event_base_dispatch(struct event_base *event_base)
|
||||
const char *
|
||||
event_base_get_method(struct event_base *base)
|
||||
{
|
||||
assert(base);
|
||||
EVUTIL_ASSERT(base);
|
||||
return (base->evsel->name);
|
||||
}
|
||||
|
||||
@ -1094,7 +1093,7 @@ event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, shor
|
||||
{
|
||||
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 *
|
||||
@ -1256,7 +1255,7 @@ event_add_internal(struct event *ev, const struct timeval *tv)
|
||||
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
|
||||
@ -1387,7 +1386,7 @@ event_del_internal(struct event *ev)
|
||||
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) {
|
||||
@ -1547,8 +1546,8 @@ timeout_next(struct event_base *base, struct timeval **tv_p)
|
||||
|
||||
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:
|
||||
|
21
evmap.c
21
evmap.c
@ -48,7 +48,6 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "event-internal.h"
|
||||
@ -127,7 +126,7 @@ HT_GENERATE(event_io_map, event_map_entry, map_node, hashsocket, eqsocket,
|
||||
}, \
|
||||
{ \
|
||||
_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) \
|
||||
@ -163,10 +162,10 @@ void evmap_io_clear(struct event_io_map *ctx)
|
||||
#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]); \
|
||||
@ -265,7 +264,7 @@ evmap_io_add(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
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? */
|
||||
|
||||
@ -330,7 +329,7 @@ evmap_io_del(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
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? */
|
||||
|
||||
@ -352,12 +351,12 @@ evmap_io_del(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
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) {
|
||||
@ -382,11 +381,11 @@ evmap_io_active(struct event_base *base, evutil_socket_t fd, short events)
|
||||
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);
|
||||
@ -455,7 +454,7 @@ evmap_signal_active(struct event_base *base, int sig, int ncalls)
|
||||
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)
|
||||
|
20
evport.c
20
evport.c
@ -55,7 +55,6 @@
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <assert.h>
|
||||
#include <sys/queue.h>
|
||||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
@ -66,9 +65,6 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#ifdef CHECK_INVARIANTS
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#include "event-internal.h"
|
||||
#include "log-internal.h"
|
||||
@ -176,10 +172,10 @@ evport_init(struct event_base *base)
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -194,8 +190,8 @@ check_event(port_event_t* pevt)
|
||||
* 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
|
||||
@ -212,7 +208,7 @@ grow(struct evport_data *epdp, int factor)
|
||||
struct fd_info *tmp;
|
||||
int oldsize = epdp->ed_nevents;
|
||||
int newsize = factor * oldsize;
|
||||
assert(factor > 1);
|
||||
EVUTIL_ASSERT(factor > 1);
|
||||
|
||||
check_evportop(epdp);
|
||||
|
||||
@ -346,7 +342,7 @@ evport_dispatch(struct event_base *base, struct timeval *tv)
|
||||
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);
|
||||
|
45
evrpc.c
45
evrpc.c
@ -51,7 +51,6 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
@ -100,17 +99,17 @@ evrpc_free(struct evrpc_base *base)
|
||||
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);
|
||||
}
|
||||
@ -132,11 +131,11 @@ evrpc_add_hook(void *vbase,
|
||||
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;
|
||||
@ -177,7 +176,7 @@ evrpc_remove_hook(void *vbase, enum EVRPC_HOOK_TYPE hook_type, void *handle)
|
||||
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));
|
||||
@ -268,7 +267,7 @@ evrpc_unregister_rpc(struct evrpc_base *base, const char *name)
|
||||
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);
|
||||
@ -316,7 +315,7 @@ evrpc_request_cb(struct evhttp_request *req, void *arg)
|
||||
case EVRPC_CONTINUE:
|
||||
break;
|
||||
default:
|
||||
assert(hook_res == EVRPC_TERMINATE ||
|
||||
EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE ||
|
||||
hook_res == EVRPC_CONTINUE ||
|
||||
hook_res == EVRPC_PAUSE);
|
||||
}
|
||||
@ -376,7 +375,7 @@ void
|
||||
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 */
|
||||
@ -432,7 +431,7 @@ evrpc_request_done(struct evrpc_req_generic *rpc_state)
|
||||
case EVRPC_CONTINUE:
|
||||
break;
|
||||
default:
|
||||
assert(hook_res == EVRPC_TERMINATE ||
|
||||
EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE ||
|
||||
hook_res == EVRPC_CONTINUE ||
|
||||
hook_res == EVRPC_PAUSE);
|
||||
}
|
||||
@ -535,11 +534,11 @@ evrpc_pool_free(struct evrpc_pool *pool)
|
||||
}
|
||||
|
||||
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);
|
||||
@ -554,7 +553,7 @@ void
|
||||
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);
|
||||
|
||||
/*
|
||||
@ -671,7 +670,7 @@ evrpc_schedule_request(struct evhttp_connection *connection,
|
||||
/* 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);
|
||||
}
|
||||
@ -778,7 +777,7 @@ evrpc_make_request(struct evrpc_request_wrapper *ctx)
|
||||
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,
|
||||
@ -872,7 +871,7 @@ evrpc_reply_done(struct evhttp_request *req, void *arg)
|
||||
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);
|
||||
}
|
||||
@ -945,7 +944,7 @@ evrpc_request_timeout(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -958,7 +957,7 @@ static void
|
||||
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);
|
||||
@ -973,7 +972,7 @@ evrpc_hook_meta_new(void)
|
||||
{
|
||||
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;
|
||||
@ -1010,10 +1009,10 @@ evrpc_hook_add_meta(void *ctx, const char *key,
|
||||
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);
|
||||
|
35
http.c
35
http.c
@ -62,7 +62,6 @@
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -224,7 +223,7 @@ static char *
|
||||
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;
|
||||
@ -597,7 +596,7 @@ evhttp_connection_fail(struct evhttp_connection *evcon,
|
||||
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);
|
||||
|
||||
@ -914,9 +913,9 @@ evhttp_write_connectioncb(struct evhttp_connection *evcon, void *arg)
|
||||
{
|
||||
/* 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;
|
||||
@ -972,7 +971,7 @@ void
|
||||
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)
|
||||
@ -983,7 +982,7 @@ void
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1000,7 +999,7 @@ evhttp_request_dispatch(struct evhttp_connection* evcon)
|
||||
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;
|
||||
|
||||
@ -1125,12 +1124,12 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg)
|
||||
*/
|
||||
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;
|
||||
}
|
||||
@ -1749,8 +1748,8 @@ void
|
||||
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);
|
||||
}
|
||||
@ -1800,7 +1799,7 @@ evhttp_connection_connect(struct evhttp_connection *evcon)
|
||||
|
||||
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(
|
||||
@ -1859,9 +1858,9 @@ evhttp_make_request(struct evhttp_connection *evcon,
|
||||
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);
|
||||
|
||||
@ -1933,7 +1932,7 @@ evhttp_send_done(struct evhttp_connection *evcon, void *arg)
|
||||
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) {
|
||||
@ -1983,7 +1982,7 @@ evhttp_send(struct evhttp_request *req, struct evbuffer *databuf)
|
||||
{
|
||||
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)
|
||||
@ -2902,7 +2901,7 @@ addr_from_name(char *address)
|
||||
|
||||
return (aitop);
|
||||
#else
|
||||
assert(0);
|
||||
EVUTIL_ASSERT(0);
|
||||
return NULL; /* XXXXX Use gethostbyname, if this function is ever used. */
|
||||
#endif
|
||||
}
|
||||
|
5
kqueue.c
5
kqueue.c
@ -44,7 +44,6 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#ifdef _EVENT_HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
@ -419,7 +418,7 @@ kq_sig_add(struct event_base *base, int nsignal, short old, short events, void *
|
||||
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;
|
||||
@ -447,7 +446,7 @@ kq_sig_del(struct event_base *base, int nsignal, short old, short events, void *
|
||||
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;
|
||||
|
13
poll.c
13
poll.c
@ -44,7 +44,6 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "event-internal.h"
|
||||
#include "evsignal-internal.h"
|
||||
@ -108,11 +107,11 @@ poll_check_ok(struct pollop *pop)
|
||||
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
|
||||
@ -214,7 +213,7 @@ poll_add(struct event_base *base, int fd, short old, short events, void *_idx)
|
||||
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);
|
||||
|
||||
@ -275,7 +274,7 @@ poll_del(struct event_base *base, int fd, short old, short events, void *_idx)
|
||||
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);
|
||||
|
||||
@ -307,8 +306,8 @@ poll_del(struct event_base *base, int fd, short old, short events, void *_idx)
|
||||
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;
|
||||
}
|
||||
|
||||
|
5
select.c
5
select.c
@ -46,7 +46,6 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "event-internal.h"
|
||||
#include "evsignal-internal.h"
|
||||
@ -245,7 +244,7 @@ select_add(struct event_base *base, int fd, short old, short events, void *p)
|
||||
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
|
||||
@ -290,7 +289,7 @@ select_del(struct event_base *base, int fd, short old, short events, void *p)
|
||||
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) {
|
||||
|
5
signal.c
5
signal.c
@ -55,7 +55,6 @@
|
||||
#ifdef _EVENT_HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#include "event2/event.h"
|
||||
#include "event2/event_struct.h"
|
||||
@ -217,7 +216,7 @@ evsig_add(struct event_base *base, int evsignal, short old, short events, void *
|
||||
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)
|
||||
@ -269,7 +268,7 @@ _evsig_restore_handler(struct event_base *base, int evsignal)
|
||||
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));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user