In message <[email protected]>, Mar
tin Blix Grydeland writes:

I may have asked this before, but why not simply make a
local VTAILQ_HEAD on the stack and move everything there in one
iteration ?

Is it to not block the mutex'es too long ?

Poul-Henning

PS: This email is _also_ a sort of test of patchwork :-)

>+#define NUKEBUF 10
>+
>+void
>+EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru)
>+{
>+      struct objcore *oc;
>+      struct objcore *oc_array[NUKEBUF];
>+      struct object *o;
>+      int i, n;
>+      double t;
>+
>+      CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
>+      CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
>+
>+      t = VTIM_real();
>+      Lck_Lock(&lru->mtx);
>+      while (!VTAILQ_EMPTY(&lru->lru_head)) {
>+              Lck_Lock(&exp_mtx);
>+              n = 0;
>+              while (n < NUKEBUF) {
>+                      oc = VTAILQ_FIRST(&lru->lru_head);
>+                      if (oc == NULL)
>+                              break;
>+                      CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
>+                      assert(oc_getlru(oc) == lru);
>+
>+                      /* Remove from the LRU and binheap */
>+                      VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
>+                      assert(oc->timer_idx != BINHEAP_NOIDX);
>+                      binheap_delete(exp_heap, oc->timer_idx);
>+                      assert(oc->timer_idx == BINHEAP_NOIDX);
>+
>+                      oc_array[n++] = oc;
>+                      VSC_C_main->n_lru_nuked++;
>+              }




-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
[email protected]         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to