Browse code

http_async_module: check return for event_base_dispatch()

- exit if it fails
- part of GH #2999

(cherry picked from commit 461ec0a79ae365729c11efcbd96fc158c50a2891)

Daniel-Constantin Mierla authored on 10/01/2022 17:33:53
Showing 2 changed files
... ...
@@ -48,6 +48,7 @@
48 48
 #include "../../core/receive.h"
49 49
 #include "../../core/fmsg.h"
50 50
 #include "../../core/kemi.h"
51
+#include "../../core/daemonize.h"
51 52
 #include "../../modules/tm/tm_load.h"
52 53
 
53 54
 #include "async_http.h"
... ...
@@ -89,8 +90,12 @@ int async_http_init_worker(int prank, async_http_worker_t* worker)
89 90
 
90 91
 void async_http_run_worker(async_http_worker_t* worker)
91 92
 {
93
+	int ret;
92 94
 	init_http_multi(worker->evbase, worker->g);
93
-	event_base_dispatch(worker->evbase);
95
+	ret = event_base_dispatch(worker->evbase);
96
+	LM_ERR("event base dispatch failed - ret: %d (errno: %d - %s)\n", ret, errno,
97
+			strerror(errno));
98
+	ksr_exit(-1);
94 99
 }
95 100
 
96 101
 int async_http_init_sockets(async_http_worker_t *worker)
... ...
@@ -325,7 +325,7 @@ static int child_init(int rank)
325 325
 	int pid;
326 326
 	int i;
327 327
 
328
-	LM_DBG("child initializing async http\n");
328
+	LM_DBG("child initializing async http (rank: %d)\n", rank);
329 329
 
330 330
 	if(num_workers<=0)
331 331
 		return 0;
... ...
@@ -336,7 +336,7 @@ static int child_init(int rank)
336 336
 
337 337
 	if (rank==PROC_INIT) {
338 338
 		for(i=0; i<num_workers; i++) {
339
-			LM_DBG("initializing worker notification socket: %d\n", i);
339
+			LM_DBG("initializing worker notification socket: %d (rank: %d)\n", i, rank);
340 340
 			if(async_http_init_sockets(&workers[i])<0) {
341 341
 				LM_ERR("failed to initialize tasks sockets\n");
342 342
 				return -1;