]> mj.ucw.cz Git - libucw.git/blobdiff - lib/workqueue.c
Added the local copy of the regex library back.
[libucw.git] / lib / workqueue.c
index 1e2bcb1c2cbfd4fcbefcfa09bc7add95b6b47485..8833e46f9d7a5ebcc29f5c4cc32e8e64d8a44b09 100644 (file)
@@ -128,7 +128,7 @@ raw_queue_put(struct raw_queue *q, struct work *w)
        {
          struct work **old_heap = q->pri_heap;
          q->heap_max = (q->heap_max ? 2*q->heap_max : 16);
-         q->pri_heap = xrealloc(old_heap, q->heap_max * sizeof(struct work *));
+         q->pri_heap = xrealloc(old_heap, (q->heap_max + 1) * sizeof(struct work *));
        }
       struct work **heap = q->pri_heap;
       heap[++q->heap_cnt] = w;
@@ -202,18 +202,13 @@ work_submit(struct work_queue *q, struct work *w)
 static struct work *
 work_do_wait(struct work_queue *q, int try)
 {
-  while (q->nr_running)
-    {
-      struct work *w = (try ? raw_queue_try_get : raw_queue_get)(&q->finished);
-      if (!w)
-       return NULL;
-      q->nr_running--;
-      if (w->returned)
-       w->returned(q, w);
-      else
-       return w;
-    }
-  return NULL;
+  if (!q->nr_running)
+    return NULL;
+  struct work *w = (try ? raw_queue_try_get : raw_queue_get)(&q->finished);
+  if (!w)
+    return NULL;
+  q->nr_running--;
+  return w;
 }
 
 struct work *