return (NULL);
}
sp = SES_New(addr, l);
- assert(sp != NULL); /* XXX handle */
+ XXXAN(sp);
(void)clock_gettime(CLOCK_REALTIME, &sp->t_open);
sp->fd = i;
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- assert(sp->obj == NULL);
- assert(sp->vcl == NULL);
+ AZ(sp->obj);
+ AZ(sp->vcl);
if (sp->fd >= 0) {
VSL(SLT_SessionReuse, sp->fd, "%s %s", sp->addr, sp->port);
(void)clock_gettime(CLOCK_REALTIME, &sp->t_open);
vca_kq_sess(struct sess *sp, int arm)
{
struct kevent ke;
- int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->fd < 0)
return;
EV_SET(&ke, sp->fd, EVFILT_READ, arm, 0, 0, sp);
- i = kevent(kq, &ke, 1, NULL, 0, NULL);
- assert(i == 0);
+ AZ(kevent(kq, &ke, 1, NULL, 0, NULL));
}
static void
int i;
struct sess *sp;
- assert(kp->udata != NULL);
+ AN(kp->udata);
if (kp->udata == pipes) {
while (kp->data > 0) {
i = read(pipes[0], &sp, sizeof sp);
vca_kqueue_main(void *arg)
{
struct kevent ke[NKEV], *kp;
- int i, j, n;
+ int j, n;
struct timespec ts;
struct sess *sp;
j = 0;
EV_SET(&ke[j++], 0, EVFILT_TIMER, EV_ADD, 0, 100, NULL);
EV_SET(&ke[j++], pipes[0], EVFILT_READ, EV_ADD, 0, 0, pipes);
- i = kevent(kq, ke, j, NULL, 0, NULL);
- assert(i == 0);
+ AZ(kevent(kq, ke, j, NULL, 0, NULL));
while (1) {
n = kevent(kq, NULL, 0, ke, NKEV, NULL);
u += u;
VSL(SLT_Debug, 0, "Acceptor Pollspace %u", u);
p = realloc(pollfd, u * sizeof *p);
- assert(p != NULL);
+ XXXAN(p); /* close offending fd */
memset(p + npoll, 0, (u - npoll) * sizeof *p);
for (v = npoll ; v <= u; v++)
p->fd = -1;
char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE];
struct addrinfo *ai;
- assert(bp != NULL);
- assert(bp->hostname != NULL);
+ CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
+ AN(bp->hostname);
s = vbe_conn_try(bp, &ai);
if (s < 0)
vc = vbe_new_conn();
else
vc = vc2;
- assert(vc != NULL);
+ AN(vc);
assert(vc->fd == -1);
- assert(vc->backend == NULL);
+ AZ(vc->backend);
}
/* If not connected yet, do so */
if (vc->fd < 0) {
- assert(vc->backend == NULL);
+ AZ(vc->backend);
vc->fd = vbe_connect(bp);
LOCK(&vbemtx);
if (vc->fd < 0) {
assert(vc->fd >= 0);
VSL_stats->backend_conn++;
VSL(SLT_BackendXID, vc->fd, "%u", xid);
- assert(vc->backend != NULL);
+ AN(vc->backend);
}
return (vc);
}
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
assert(vc->fd >= 0);
- assert(vc->backend != NULL);
+ AN(vc->backend);
VSL(SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name);
if (!already)
AZ(close(vc->fd));
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
assert(vc->fd >= 0);
- assert(vc->backend != NULL);
+ AN(vc->backend);
VSL_stats->backend_recycle++;
VSL(SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
LOCK(&vbemtx);
int i;
b = calloc(sizeof *b, 1);
- assert(b != NULL);
+ XXXAN(b);
i = regcomp(&b->regexp, regexp, REG_EXTENDED | REG_NOSUB);
if (i) {
double dh, dp, da;
struct timespec te;
- assert(sp->obj == NULL);
- assert(sp->vbc == NULL);
+ AZ(sp->obj);
+ AZ(sp->vbc);
if (sp->fd >= 0 && sp->doclose != NULL)
vca_close_session(sp, sp->doclose);
sp->backend = NULL;
cnt_fetch(struct sess *sp)
{
- assert(sp->vbc != NULL);
+ CHECK_OBJ_NOTNULL(sp->vbc, VBE_CONN_MAGIC);
RFC2616_cache_policy(sp, sp->vbc->http);
VCL_fetch_method(sp);
}
if (sp->handling == VCL_RET_INSERT) {
sp->obj->cacheable = 1;
- assert(sp->vbc != NULL);
FetchBody(sp);
- assert(sp->vbc == NULL);
+ AZ(sp->vbc);
HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */
HSH_Unbusy(sp->obj);
sp->wrk->acct.fetch++;
cnt_lookup(struct sess *sp)
{
- assert(sp->obj == NULL);
+ AZ(sp->obj);
sp->step = STP_LOOKUP2;
return (0);
}
if (sp->handling == VCL_RET_LOOKUP)
INCOMPL();
if (sp->handling == VCL_RET_FETCH) {
- assert(sp->vbc == NULL);
+ AZ(sp->vbc);
FetchHeaders(sp);
sp->step = STP_FETCH;
- assert(sp->vbc != NULL);
+ AN(sp->vbc);
return (0);
}
INCOMPL();
cnt_pass(struct sess *sp)
{
- assert(sp->vbc == NULL);
+ AZ(sp->vbc);
if (!PassSession(sp)) {
- assert(sp->vbc != NULL);
+ AN(sp->vbc);
sp->step = STP_PASSBODY;
} else
sp->step = STP_DONE;
{
sp->wrk->acct.pass++;
- assert(sp->vbc != NULL);
+ AN(sp->vbc);
PassBody(sp);
- assert(sp->vbc == NULL);
+ AZ(sp->vbc);
sp->step = STP_DONE;
return (0);
}
int done;
sp->t0 = time(NULL);
- assert(sp->vcl == NULL);
+ AZ(sp->vcl);
sp->vcl = VCL_Get();
- assert(sp->obj == NULL);
- assert(sp->vbc == NULL);
+ AZ(sp->obj);
+ AZ(sp->vbc);
sp->wrk->acct.req++;
done = http_DissectRequest(sp->http, sp->fd);
memset(cli, 0, sizeof *cli);
cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
- assert(cli->sb != NULL);
+ XXXAN(cli->sb);
lbuf = 4096;
buf = malloc(lbuf);
- assert(buf != NULL);
+ XXXAN(buf);
nbuf = 0;
while (1) {
pfd[0].fd = heritage.fds[2];
if ((nbuf + 2) >= lbuf) {
lbuf += lbuf;
buf = realloc(buf, lbuf);
- assert(buf != NULL);
+ XXXAN(buf);
}
i = read(heritage.fds[2], buf + nbuf, lbuf - nbuf);
if (i <= 0) {
(void)arg;
sp = SES_New(NULL, 0);
- assert(sp != NULL);
+ XXXAN(sp);
while (1) {
t = time(NULL);
LOCK(&exp_mtx);
AZ(pthread_mutex_init(&exp_mtx, NULL));
exp_heap = binheap_new(NULL, object_cmp, object_update);
- assert(exp_heap != NULL);
+ XXXAN(exp_heap);
AZ(pthread_create(&exp_thread, NULL, exp_prefetch, NULL));
AZ(pthread_create(&exp_thread, NULL, exp_hangman, NULL));
}
cl = strtoumax(b, NULL, 0);
st = stevedore->alloc(stevedore, cl);
- assert(st->stevedore != NULL);
+ XXXAN(st->stevedore);
TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
st->len = cl;
sp->obj->len = cl;
while (cl > 0) {
i = http_Read(hp, fd, p, cl);
- assert(i > 0); /* XXX seen */
+ xxxassert(i > 0); /* XXX seen */
p += i;
cl -= i;
}
st = NULL;
while (1) {
i = http_Read(hp, fd, bp, be - bp);
- assert(i >= 0);
+ xxxassert(i >= 0);
bp += i;
*bp = '\0';
u = strtoul(buf, &q, 16);
if (q == NULL || q == buf)
continue;
- assert(isspace(*q));
+ xxxassert(isspace(*q));
while (*q == '\t' || *q == ' ')
q++;
if (*q == '\r')
q++;
- assert(*q == '\n');
+ xxxassert(*q == '\n');
q++;
if (u == 0)
break;
} else {
st = stevedore->alloc(stevedore,
stevedore->trim == NULL ? u : CHUNK_PREALLOC);
- assert(st->stevedore != NULL);
+ XXXAN(st->stevedore);
TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
p = st->ptr;
}
v = u;
i = bp - q;
+ assert(i >= 0);
if (i == 0) {
} else if (v > i) {
- assert(i > 0);
memcpy(p, q, i);
p += i;
st->len += i;
continue;
while (v > 0) {
i = http_Read(hp, fd, p, v);
- assert(i > 0);
st->len += i;
v -= i;
u -= i;
while (1) {
if (v == 0) {
st = stevedore->alloc(stevedore, CHUNK_PREALLOC);
- assert(st->stevedore != NULL);
+ XXXAN(st->stevedore);
TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
p = st->ptr + st->len;
v = st->space - st->len;
}
- assert(p != NULL);
- assert(st != NULL);
+ AN(p);
+ AN(st);
i = http_Read(hp, fd, p, v);
- assert(i >= 0);
+ xxxassert(i >= 0);
if (i == 0)
break;
p += i;
vc = VBE_GetFd(sp->backend, sp->xid);
if (vc == NULL)
vc = VBE_GetFd(sp->backend, sp->xid);
- assert(vc != NULL); /* XXX: handle this */
+ XXXAN(vc);
VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
http_ClrHeader(vc->http);
WRK_Reset(w, &vc->fd);
http_Write(w, vc->http, 0);
i = WRK_Flush(w);
- assert(i == 0);
+ xxxassert(i == 0);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
i = http_RecvHead(vc->http, vc->fd);
- assert(i == 0);
- assert(http_DissectResponse(vc->http, vc->fd) == 0);
+ xxxassert(i == 0);
+ xxxassert(http_DissectResponse(vc->http, vc->fd) == 0);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
- assert(sp->vbc == NULL);
+ AZ(sp->vbc);
sp->vbc = vc;
sp->obj->entered = time(NULL);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC);
- assert(hash != NULL);
+ AN(hash);
w = sp->wrk;
h = sp->http;
/* Precreate an objhead and object in case we need them */
if (w->nobjhead == NULL) {
w->nobjhead = calloc(sizeof *w->nobjhead, 1);
- assert(w->nobjhead != NULL);
+ XXXAN(w->nobjhead);
w->nobjhead->magic = OBJHEAD_MAGIC;
TAILQ_INIT(&w->nobjhead->objects);
AZ(pthread_mutex_init(&w->nobjhead->mtx, NULL));
CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC);
if (w->nobj == NULL) {
w->nobj = calloc(sizeof *w->nobj, 1);
- assert(w->nobj != NULL);
+ XXXAN(w->nobj);
w->nobj->magic = OBJECT_MAGIC;
w->nobj->http.magic = HTTP_MAGIC;
w->nobj->busy = 1;
{
struct sess *sp;
- assert(o != NULL);
+ CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(o->busy);
assert(o->refcnt > 0);
if (o->cacheable)
{
unsigned l;
- assert(hh->b != NULL);
- assert(hh->e != NULL);
- assert(hdr != NULL);
+ AN(hh->b);
+ AN(hh->e);
+ AN(hdr);
l = hdr[0];
assert(l == strlen(hdr + 1));
assert(hdr[l] == ':');
unsigned u;
for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
- assert(hp->hd[u].b != NULL);
- assert(hp->hd[u].e != NULL);
+ AN(hp->hd[u].b);
+ AN(hp->hd[u].e);
if (hp->hd[u].e < hp->hd[u].b + l + 1)
continue;
if (hp->hd[u].b[l] != ':')
if (!http_GetHdr(hp, hdr, &p))
return (0);
- assert(p != NULL);
+ AN(p);
if (!strcasecmp(p, val))
return (1);
return (0);
http_GetStatus(struct http *hp)
{
- assert(hp->hd[HTTP_HDR_STATUS].b != NULL);
+ AN(hp->hd[HTTP_HDR_STATUS].b);
return (strtoul(hp->hd[HTTP_HDR_STATUS].b,
NULL /* XXX */, 10));
}
{
char *p;
- assert(hp->t != NULL);
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+ AN(hp->t);
assert(hp->s < hp->t);
assert(hp->t <= hp->v);
hp->logtag = HTTP_Rx;
{
char *p, *q;
- assert(hp->t != NULL);
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+ AN(hp->t);
assert(hp->s < hp->t);
assert(hp->t <= hp->v);
hp->logtag = HTTP_Rx;
{
char *p;
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
assert(hp->v <= hp->e);
assert(*hp->v == '\0');
/* Skip any leading white space */
for (u = 0; u < fm->nhd; u++) {
if (fm->hd[u].b == NULL)
continue;
- assert(fm->hd[u].e != NULL);
+ AN(fm->hd[u].e);
l += (fm->hd[u].e - fm->hd[u].b) + 1;
}
to->s = malloc(l);
- assert(to->s != NULL);
+ XXXAN(to->s);
to->e = to->s + l;
to->f = to->s;
for (u = 0; u < fm->nhd; u++) {
if (fm->hd[u].b == NULL)
continue;
- assert(fm->hd[u].e != NULL);
+ AN(fm->hd[u].e);
assert(*fm->hd[u].e == '\0');
l = fm->hd[u].e - fm->hd[u].b;
assert(l == strlen(fm->hd[u].b));
static void
http_seth(int fd, struct http *to, unsigned n, enum httptag tag, const char *fm)
{
+
assert(n < HTTP_HDR_MAX);
- assert(fm != NULL);
+ AN(fm);
to->hd[n].b = (void*)(uintptr_t)fm;
to->hd[n].e = (void*)(uintptr_t)strchr(fm, '\0');
to->hdf[n] = 0;
{
assert(n < HTTP_HDR_MAX);
- assert(fm->hd[n].b != NULL);
+ AN(fm->hd[n].b);
to->hd[n].b = fm->hd[n].b;
to->hd[n].e = fm->hd[n].e;
to->hdf[n] = fm->hdf[n];
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
assert(n < HTTP_HDR_MAX);
- assert(fm->hd[n].b != NULL);
+ AN(fm->hd[n].b);
if (to->nhd < HTTP_HDR_MAX) {
to->hd[to->nhd].b = fm->hd[n].b;
to->hd[to->nhd].e = fm->hd[n].e;
unsigned u, l;
if (resp) {
- assert(hp->hd[HTTP_HDR_STATUS].b != NULL);
+ AN(hp->hd[HTTP_HDR_STATUS].b);
l = WRK_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " ");
l += WRK_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " ");
l += WRK_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
} else {
- assert(hp->hd[HTTP_HDR_URL].b != NULL);
+ AN(hp->hd[HTTP_HDR_URL].b);
l = WRK_WriteH(w, &hp->hd[HTTP_HDR_REQ], " ");
l += WRK_WriteH(w, &hp->hd[HTTP_HDR_URL], " ");
l += WRK_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n");
}
for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
- assert(hp->hd[u].b != NULL);
- assert(hp->hd[u].e != NULL);
+ AN(hp->hd[u].b);
+ AN(hp->hd[u].e);
l += WRK_WriteH(w, &hp->hd[u], "\r\n");
}
l += WRK_Write(w, "\r\n", -1);
vca_close_session(sp, "backend closed");
return (1);
}
- assert(i > 0);
sp->wrk->acct.bodybytes += WRK_Write(sp->wrk, buf, i);
if (WRK_Flush(sp->wrk))
vca_close_session(sp, "remote closed");
p = buf;
while (1) {
i = http_Read(hp, fd, bp, be - bp);
- assert(i >= 0);
+ xxxassert(i >= 0);
if (i == 0 && p == bp)
break;
bp += i;
if (j > be - bp)
j = be - bp;
i = http_Read(hp, fd, bp, j);
- assert(i > 0);
+ xxxassert(i > 0);
bp += i;
}
}
char *b;
int cls;
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->vbc, VBE_CONN_MAGIC);
vc = sp->vbc;
- assert(vc != NULL);
sp->vbc = NULL;
clock_gettime(CLOCK_REALTIME, &sp->t_resp);
RES_Error(sp, 503, "Backend did not respond.");
return (1);
}
- assert(vc != NULL);
VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
http_CopyReq(vc->fd, vc->http, sp->http);
WRK_Reset(w, &vc->fd);
http_Write(w, vc->http, 0);
i = WRK_Flush(w);
- assert(i == 0);
+ xxxassert(i == 0);
/* XXX: copy any contents */
i = http_RecvHead(vc->http, vc->fd);
- assert(i == 0);
+ xxxassert(i == 0);
http_DissectResponse(vc->http, vc->fd);
assert(sp->vbc == NULL);
RES_Error(sp, 503, "Backend did not respond.");
return;
}
- assert(vc != NULL);
VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
vc->http->logtag = HTTP_Tx;
unsigned u;
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
- assert(w != NULL);
- assert(hh != NULL);
- assert(hh->b != NULL);
- assert(hh->e != NULL);
+ AN(w);
+ AN(hh);
+ AN(hh->b);
+ AN(hh->e);
u = WRK_Write(w, hh->b, hh->e - hh->b);
if (suf != NULL)
u += WRK_Write(w, suf, -1);
struct workreq *wrq;
wrq = TAILQ_FIRST(&wrk_reqhead);
- assert(wrq != NULL);
+ AN(wrq);
VSL_stats->n_wrk_busy++;
TAILQ_REMOVE(&wrk_reqhead, wrq, list);
VSL_stats->n_wrk_queue--;
}
sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
- assert(sb != NULL);
+ XXXAN(sb);
assert(code >= 100 && code <= 999);
if (msg == NULL) {
TAILQ_FOREACH(st, &sp->obj->store, list) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
- assert(st->stevedore != NULL);
+ AN(st->stevedore);
u += st->len;
sp->wrk->acct.bodybytes += st->len;
#ifdef HAVE_SENDFILE
struct srcaddrhead *ch;
time_t now;
- assert(sp->srcaddr == NULL);
+ AZ(sp->srcaddr);
for (u = 0, p = sp->addr; *p; p++)
u += u + *p;
v = u % CLIENT_HASH;
}
if (c3 == NULL) {
c3 = malloc(sizeof *c3);
- assert(c3 != NULL);
+ XXXAN(c3);
if (c3 != NULL)
VSL_stats->n_srcaddr++;
} else
TAILQ_REMOVE(ch, c3, list);
- assert (c3 != NULL);
+ AN(c3);
if (c3 != NULL) {
memset(c3, 0, sizeof *c3);
strcpy(c3->addr, sp->addr);
/* If we never get to work pool (illegal req) */
return;
}
- assert(sp->srcaddr != NULL);
+ AN(sp->srcaddr);
LOCK(&ses_mtx);
assert(sp->srcaddr->nref > 0);
sp->srcaddr->nref--;
sm->sess.http = &sm->http;
sm->sess.sockaddr = sm->sockaddr;
- assert(len < sizeof(sm->sockaddr));
+ assert(len < sizeof(sm->sockaddr));
if (addr != NULL) {
memcpy(sm->sess.sockaddr, addr, len);
sm->sess.sockaddrlen = len;
sm = sp->mem;
CHECK_OBJ_NOTNULL(sm, SESSMEM_MAGIC);
- assert(sp->obj == NULL);
- assert(sp->vcl == NULL);
+ AZ(sp->obj);
+ AZ(sp->vcl);
VSL_stats->n_sess--;
ses_relsrcaddr(sp);
VSL(SLT_StatSess, sp->id, "%s %s %d %ju %ju %ju %ju %ju %ju %ju",
struct VCL_conf *vc;
LOCK(&vcl_mtx);
- assert(vcl_active != NULL);
+ AN(vcl_active);
vc = vcl_active->conf;
- assert(vc != NULL);
+ AN(vc);
vc->busy++;
UNLOCK(&vcl_mtx);
return (vc);
}
vcl = calloc(sizeof *vcl, 1);
- assert(vcl != NULL);
+ XXXAN(vcl);
vcl->dlh = dlopen(fn, RTLD_NOW | RTLD_LOCAL);
}
vcl->conf->priv = vcl;
vcl->name = strdup(name);
- assert(vcl->name != NULL);
+ XXXAN(vcl->name);
TAILQ_INSERT_TAIL(&vcl_head, vcl, list);
LOCK(&vcl_mtx);
if (vcl_active == NULL)
char *p;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- assert(sp != NULL);
- assert(sp->http != NULL);
+ AN(sp->http);
if (!http_GetHdr(sp->http, n, &p))
return (NULL);
return (p);
int i;
cp->backend = calloc(sizeof *cp->backend, cp->nbackend);
- assert(cp->backend != NULL);
+ XXXAN(cp->backend);
for (i = 0; i < cp->nbackend; i++) {
cp->backend[i] = calloc(sizeof *cp->backend[i], 1);
- assert(cp->backend[i] != NULL);
+ XXXAN(cp->backend[i]);
cp->backend[i]->magic = BACKEND_MAGIC;
TAILQ_INIT(&cp->backend[i]->connlist);
}
vrt_acl_vsl(struct sess *sp, const char *acl, struct vrt_acl *ap, int r)
{
- assert(ap != NULL);
+ AN(ap);
if (ap->name == NULL) {
assert(r == 0);
VSL(SLT_VCL_acl, sp->fd, "NO_MATCH %s", acl);
VRT_re_init(void **rep, const char *re)
{
regex_t *t;
- int i;
t = calloc(sizeof *t, 1);
- assert(t != NULL);
- i = regcomp(t, re, REG_EXTENDED | REG_NOSUB);
- assert(i == 0);
+ XXXAN(t);
+ /* This was already check-compiled by the VCL compiler */
+ AZ(regcomp(t, re, REG_EXTENDED | REG_NOSUB));
*rep = t;
}
if (s == NULL)
return (0);
- assert(re != NULL);
+ AN(re);
t = re;
i = regexec(t, s, 0, NULL, 0);
if (i == 0)
-sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 ))
-sem(lbv_assert, r_no)
+-sem(lbv_xxxassert, r_no)
-ffc // No automatic custody
unsigned u;
hcl_head = calloc(sizeof *hcl_head, hcl_nhash);
- assert(hcl_head != NULL);
+ XXXAN(hcl_head);
for (u = 0; u < hcl_nhash; u++) {
TAILQ_INIT(&hcl_head[u].head);
i = sizeof *he2 + kl;
he2 = calloc(i, 1);
- assert(he2 != NULL);
+ XXXAN(he2);
he2->magic = HCL_ENTRY_MAGIC;
he2->oh = noh;
he2->digest = digest;
return (NULL);
}
he2 = calloc(sizeof *he2, 1);
- assert(he2 != NULL);
+ XXXAN(he2);
he2->obj = nobj;
he2->refcnt = 1;
he2->key1 = strdup(key1);
- assert(he2->key1 != NULL);
+ XXXAN(he2->key1);
he2->key2 = strdup(key2);
- assert(he2->key2 != NULL);
+ XXXAN(he2->key2);
nobj->hashpriv = he2;
if (he != NULL)
TAILQ_INSERT_BEFORE(he, he2, list);
struct hsl_entry *he;
int ret;
- assert(obj->hashpriv != NULL);
+ AN(obj->hashpriv);
he = obj->hashpriv;
LOCK(&hsl_mutex);
if (--he->refcnt == 0) {
/* Redirect stdin/out/err */
AZ(close(0));
i = open("/dev/null", O_RDONLY);
- assert(i == 0);
+ xxxassert(i == 0);
assert(dup2(child_fds[1], 1) == 1);
assert(dup2(child_fds[1], 2) == 2);
AZ(close(child_fds[0]));
AZ(close(child_fds[1]));
child_fds[1] = -1;
- assert(ev_listen == NULL);
+ AZ(ev_listen);
e = ev_new();
- assert(e != NULL);
+ XXXAN(e);
e->fd = child_fds[0];
e->fd_flags = EV_RD;
e->name = "Child listener";
AZ(ev_add(mgt_evb, e));
ev_listen = e;
- assert(ev_poker == NULL);
+ AZ(ev_poker);
e = ev_new();
- assert(e != NULL);
+ XXXAN(e);
e->timeout = 3.0;
e->callback = child_poker;
e->name = "child poker";
mgt_pid = getpid();
mgt_evb = ev_new_base();
- assert(mgt_evb != NULL);
+ XXXAN(mgt_evb);
if (dflag)
mgt_cli_setup(0, 1, 1);
mgt_cli_telnet(T_arg);
e = ev_new();
- assert(e != NULL);
+ XXXAN(e);
e->sig = SIGTERM;
e->callback = mgt_sigint;
e->name = "mgt_sigterm";
AZ(ev_add(mgt_evb, e));
e = ev_new();
- assert(e != NULL);
+ XXXAN(e);
e->sig = SIGINT;
e->callback = mgt_sigint;
e->name = "mgt_sigint";
AZ(ev_add(mgt_evb, e));
e = ev_new();
- assert(e != NULL);
+ XXXAN(e);
e->sig = SIGCHLD;
e->sig_flags = SA_NOCLDSTOP;
e->callback = mgt_sigchld;
(void)av;
(void)priv;
- assert (VSL_stats != NULL);
+ AN(VSL_stats);
#define MAC_STAT(n,t,f,d) \
cli_out(cli, "%12ju " d "\n", (VSL_stats->n));
#include "stat_field.h"
for (u = 1; av[u] != NULL; u++)
v += strlen(av[u]) + 3;
p = malloc(v);
- assert(p != NULL);
+ XXXAN(p);
q = p;
for (u = 1; av[u] != NULL; u++) {
*q++ = '"';
*q++ = '\n';
v = q - p;
i = write(cli_o, p, v);
- assert(i == v);
+ xxxassert(i == v);
free(p);
i = cli_readres(cli_i, &u, &p, 3.0);
for (cp = CLI_cmds; cp->request != NULL; cp++)
u++;
cli_proto = calloc(sizeof *cli_proto, u + 1);
- assert(cli_proto != NULL);
+ XXXAN(cli_proto);
u = 0;
for (cp = mgt_cli_proto; cp->request != NULL; cp++)
cli_proto[u++] = *cp;
if (cp->nbuf == cp->lbuf) {
cp->lbuf += cp->lbuf;
cp->buf = realloc(cp->buf, cp->lbuf);
- assert(cp->buf != NULL);
+ XXXAN(cp->buf);
}
i = read(cp->fdi, cp->buf + cp->nbuf, cp->lbuf - cp->nbuf);
if (i <= 0)
struct cli_port *cp;
cp = calloc(sizeof *cp, 1);
- assert(cp != NULL);
+ XXXAN(cp);
sprintf(cp->name, "cli %d->%d", fdi, fdo);
cp->magic = CLI_PORT_MAGIC;
cp->lbuf = 4096;
cp->buf = malloc(cp->lbuf);
- assert(cp->buf != NULL);
+ XXXAN(cp->buf);
cp->cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
- assert(cp->cli->sb != NULL);
+ XXXAN(cp->cli->sb);
cp->ev = calloc(sizeof *cp->ev, 1);
cp->ev->name = cp->name;
exit (2);
}
telnet_ev = ev_new();
- assert(telnet_ev != NULL);
+ XXXAN(telnet_ev);
telnet_ev->fd = telnet_sock;
telnet_ev->fd_flags = POLLIN;
telnet_ev->callback = telnet_accept;
q = strchr(p, '\n');
if (q == NULL)
q = strchr(p, '\0');
- assert(q != NULL);
if (q > p + 52) {
q = p + 52;
while (q > p && *q != ' ')
q--;
- assert(q != NULL);
+ AN(q);
}
cli_out(cli, "%20s %.*s\n", "", q - p, p);
p = q;
struct vclprog *vp;
vp = calloc(sizeof *vp, 1);
- assert(vp != NULL);
+ XXXAN(vp);
vp->name = strdup(name);
vp->fname = file;
TAILQ_INSERT_TAIL(&vclhead, vp, list);
{
TAILQ_REMOVE(&vclhead, vp, list);
printf("unlink %s\n", vp->fname);
- AZ(unlink(vp->fname)); /* XXX assert for now */
+ XXXAZ(unlink(vp->fname));
free(vp->fname);
free(vp->name);
free(vp);
struct vclprog *vp;
sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
- assert(sb != NULL);
+ XXXAN(sb);
if (b_arg != NULL) {
/*
* XXX: should do a "HEAD /" on the -b argument to see that
"}\n", addr, port ? port : "http");
free(addr);
free(port);
- assert(buf != NULL);
+ AN(buf);
vf = VCC_Compile(sb, buf, NULL);
free(buf);
} else {
(void)priv;
sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
- assert(sb != NULL);
+ XXXAN(sb);
vf = VCC_Compile(sb, av[3], NULL);
vsb_finish(sb);
if (vsb_len(sb) > 0) {
(void)priv;
sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
- assert(sb != NULL);
+ XXXAN(sb);
vf = VCC_CompileFile(sb, av[3]);
vsb_finish(sb);
if (vsb_len(sb) > 0) {
assert(b != NULL);
if (e == NULL)
e = strchr(b, '\0');
- assert(e != NULL);
/* Truncate */
l = e - b;
slh.ptr = 0;
slh.start = sizeof slh + sizeof *params;
i = write(heritage.vsl_fd, &slh, sizeof slh);
- assert(i == sizeof slh);
+ xxxassert(i == sizeof slh);
heritage.vsl_size = slh.start + size;
AZ(ftruncate(heritage.vsl_fd, (off_t)heritage.vsl_size));
}
PROT_READ|PROT_WRITE,
MAP_HASSEMAPHORE | MAP_NOSYNC | MAP_SHARED,
heritage.vsl_fd, 0);
- assert(loghead != MAP_FAILED);
+ xxxassert(loghead != MAP_FAILED);
VSL_stats = &loghead->stats;
pp = (void *)(loghead + 1);
memcpy(pp, params, sizeof *pp);
if (bs < fsst.f_bsize)
bs = fsst.f_bsize;
- assert(S_ISREG(st.st_mode));
+ xxxassert(S_ISREG(st.st_mode));
i = sscanf(size, "%ju%1s", &l, suff); /* can return -1, 0, 1 or 2 */
struct smf_sc *sc;
sc = calloc(sizeof *sc, 1);
- assert(sc != NULL);
+ XXXAN(sc);
TAILQ_INIT(&sc->order);
TAILQ_INIT(&sc->free);
TAILQ_INIT(&sc->used);
asprintf(&p, "%s,", spec);
else
p = strdup(spec);
- assert(p != NULL);
+ XXXAN(p);
size = strchr(p, ',');
- assert(size != NULL);
+ XXXAN(size);
*size++ = '\0';
}
asprintf(&q, "%s/varnish.XXXXXX", p);
- assert(q != NULL);
+ XXXAN(q);
sc->fd = mkstemp(q);
if (sc->fd < 0) {
fprintf(stderr,
}
AZ(unlink(q));
asprintf(&sc->filename, "%s (unlinked)", q);
- assert(sc->filename != NULL);
+ XXXAN(sc->filename);
free(q);
smf_initfile(sc, size, 1);
}
/* Split from front */
sp2 = malloc(sizeof *sp2);
- assert(sp2 != NULL);
+ XXXAN(sp2);
VSL_stats->n_smf++;
*sp2 = *sp;
assert(bytes > 0);
CHECK_OBJ_NOTNULL(sp, SMF_MAGIC);
sp2 = malloc(sizeof *sp2);
- assert(sp2 != NULL);
+ XXXAN(sp2);
VSL_stats->n_smf++;
*sp2 = *sp;
struct smf *sp, *sp2;
sp = calloc(sizeof *sp, 1);
- assert(sp != NULL);
+ XXXAN(sp);
sp->magic = SMF_MAGIC;
sp->s.magic = STORAGE_MAGIC;
VSL_stats->n_smf++;
smf = alloc_smf(sc, size);
CHECK_OBJ_NOTNULL(smf, SMF_MAGIC);
UNLOCK(&sc->mtx);
- assert(smf != NULL);
+ XXXAN(smf);
assert(smf->size == size);
smf->s.space = size;
smf->s.priv = smf;
return;
}
assert(size <= s->space);
- assert(size > 0); /* XXX: seen */
+ xxxassert(size > 0); /* XXX: seen */
CAST_OBJ_NOTNULL(smf, s->priv, SMF_MAGIC);
assert(size <= smf->size);
sc = smf->sc;
struct sma *sma;
sma = calloc(sizeof *sma, 1);
- assert(sma != NULL);
+ XXXAN(sma);
sma->s.priv = sma;
sma->s.ptr = malloc(size);
- assert(sma->s.ptr != NULL);
+ XXXAN(sma->s.ptr);
sma->s.len = 0;
sma->s.space = size;
sma->s.fd = -1;
q = p = strchr(s_arg, '\0');
else
q = p + 1;
- assert(p != NULL);
- assert(q != NULL);
+ xxxassert(p != NULL);
+ xxxassert(q != NULL);
if (!cmp_hash(&hcl_slinger, s_arg, p)) {
hp = &hcl_slinger;
} else if (!cmp_hash(&hsl_slinger, s_arg, p)) {
q = p = strchr(s_arg, '\0');
else
q = p + 1;
- assert(p != NULL);
- assert(q != NULL);
+ xxxassert(p != NULL);
+ xxxassert(q != NULL);
if (!cmp_storage(&sma_stevedore, s_arg, p)) {
stp = &sma_stevedore;
} else if (!cmp_storage(&smf_stevedore, s_arg, p)) {
i = read(pipes[1][0], buf, sizeof buf - 1);
buf[i] = '\0';
d_child = strtoul(buf, &p, 0);
- assert(p != NULL);
+ xxxassert(p != NULL);
printf("New Pid %d\n", d_child);
- assert(d_child != 0);
+ xxxassert(d_child != 0);
i = strlen(p);
j = write(pipes[1][1], p, i);
- assert(j == i);
+ xxxassert(j == i);
while (1) {
if (pfd[0].fd == -1 && pfd[1].fd == -1)