]> source.dussan.org Git - rspamd.git/commitdiff
Preserve worker's index when restaring workers.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 19 Sep 2015 20:43:51 +0000 (21:43 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Sep 2015 10:41:46 +0000 (11:41 +0100)
src/main.c

index 8b8f02f1483291f836081e9092d0e85e08ef1451..e13925d337188416664a39db020e3c882e0b81e5 100644 (file)
@@ -529,10 +529,21 @@ set_alarm (guint seconds)
 #endif
 }
 
+struct waiting_worker {
+       struct rspamd_worker_conf *cf;
+       guint oldindex;
+};
+
 static void
-delay_fork (struct rspamd_worker_conf *cf)
+delay_fork (struct rspamd_worker_conf *cf, guint index)
 {
-       workers_pending = g_list_prepend (workers_pending, cf);
+       struct waiting_worker *nw;
+
+       nw = g_slice_alloc (sizeof (*nw));
+       nw->cf = cf;
+       nw->oldindex = index;
+
+       workers_pending = g_list_prepend (workers_pending, nw);
        set_alarm (SOFT_FORK_TIME);
 }
 
@@ -605,15 +616,16 @@ static void
 fork_delayed (struct rspamd_main *rspamd)
 {
        GList *cur;
-       struct rspamd_worker_conf *cf;
+       struct waiting_worker *w;
 
        while (workers_pending != NULL) {
                cur = workers_pending;
-               cf = cur->data;
+               w = cur->data;
 
                workers_pending = g_list_remove_link (workers_pending, cur);
-               fork_worker (rspamd, cf, cf->count);
+               fork_worker (rspamd, w->cf, w->oldindex);
                g_list_free_1 (cur);
+               g_slice_free1 (sizeof (*w), w);
        }
 }
 
@@ -1319,7 +1331,7 @@ main (gint argc, gchar **argv, gchar **env)
                                                        cur->pid);
                                        }
                                        /* Fork another worker in replace of dead one */
-                                       delay_fork (cur->cf);
+                                       delay_fork (cur->cf, cur->index);
                                }
 
                                g_free (cur);