Selaa lähdekoodia

Adding a callback that is called when a new worker thread is initialized.

Johan De Taeye 9 vuotta sitten
vanhempi
commit
48dcc38096
2 muutettua tiedostoa jossa 9 lisäystä ja 0 poistoa
  1. 5 0
      include/civetweb.h
  2. 4 0
      src/civetweb.c

+ 5 - 0
include/civetweb.h

@@ -206,6 +206,11 @@ struct mg_callbacks {
 	     ctx: context handle */
 	     ctx: context handle */
 	void (*init_context)(const struct mg_context *ctx);
 	void (*init_context)(const struct mg_context *ctx);
 
 
+	/* Called when a new worker thread is initialized.
+	   Parameters:
+	     ctx: context handle */
+	void(*init_thread)(const struct mg_context *ctx);
+
 	/* Called when civetweb context is deleted.
 	/* Called when civetweb context is deleted.
 	   Parameters:
 	   Parameters:
 	     ctx: context handle */
 	     ctx: context handle */

+ 4 - 0
src/civetweb.c

@@ -12291,6 +12291,10 @@ worker_thread_run(void *thread_func_param)
 	uint32_t addr;
 	uint32_t addr;
 #endif
 #endif
 
 
+	if (ctx->callbacks.init_thread) {
+		ctx->callbacks.init_thread(ctx);
+	}
+
 	mg_set_thread_name("worker");
 	mg_set_thread_name("worker");
 
 
 	tls.is_master = 0;
 	tls.is_master = 0;