Commit 8204cb88 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Minor polishing:

Only delete empty segments from front of list.

Preallocate the temporary object-index buffer at open time.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4278 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 06e68d89
......@@ -616,16 +616,18 @@ smp_save_segs(struct smp_sc *sc)
Lck_AssertHeld(&sc->mtx);
/* Elide any empty segments from the list before we write it */
/*
* Remove empty segments from the front of the list
* before we write the segments to disk.
*/
VTAILQ_FOREACH_SAFE(sg, &sc->segments, list, sg2) {
if (sg->nobj > 0)
continue;
break;
if (sg == sc->cur_seg)
continue;
VTAILQ_REMOVE(&sc->segments, sg, list);
// XXX: free segment
free(sg);
}
smp_save_seg(sc, &sc->seg1);
smp_save_seg(sc, &sc->seg2);
}
......@@ -1042,13 +1044,9 @@ smp_new_seg(struct smp_sc *sc)
AN(sg);
sg->sc = sc;
if (sc->objbuf == NULL) {
sg->objs = malloc(sizeof *sg->objs * sc->aim_nobj);
} else {
sg->objs = sc->objbuf;
sc->objbuf = NULL;
}
AN(sc->objbuf);
sg->objs = sc->objbuf;
sc->objbuf = NULL;
AN(sg->objs);
/* XXX: debugging */
......@@ -1207,6 +1205,9 @@ smp_open(const struct stevedore *st)
Lck_New(&sc->mtx);
Lck_Lock(&sc->mtx);
sc->objbuf = malloc(sizeof *sc->objbuf * sc->aim_nobj);
AN(sc->objbuf);
/* We trust the parent to give us a valid silo, for good measure: */
AZ(smp_valid_silo(sc));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment