Browse Source

Updated patch after feedback on pull request #304

Johan De Taeye 9 years ago
parent
commit
4d8e48b78d
2 changed files with 7 additions and 6 deletions
  1. 3 2
      include/civetweb.h
  2. 4 4
      src/civetweb.c

+ 3 - 2
include/civetweb.h

@@ -208,8 +208,9 @@ struct mg_callbacks {
 
 	/* Called when a new worker thread is initialized.
 	   Parameters:
-	     ctx: context handle */
-	void(*init_thread)(const struct mg_context *ctx);
+	     ctx: context handle
+	     thread_type: a value of 1 indicates a worker thread. */
+	void(*init_thread)(const struct mg_context *ctx, int thread_type);
 
 	/* Called when civetweb context is deleted.
 	   Parameters:

+ 4 - 4
src/civetweb.c

@@ -12291,10 +12291,6 @@ worker_thread_run(void *thread_func_param)
 	uint32_t addr;
 #endif
 
-	if (ctx->callbacks.init_thread) {
-		ctx->callbacks.init_thread(ctx);
-	}
-
 	mg_set_thread_name("worker");
 
 	tls.is_master = 0;
@@ -12303,6 +12299,10 @@ worker_thread_run(void *thread_func_param)
 	tls.pthread_cond_helper_mutex = CreateEvent(NULL, FALSE, FALSE, NULL);
 #endif
 
+	if (ctx->callbacks.init_thread) {
+		ctx->callbacks.init_thread(ctx, 1);
+	}
+
 	conn =
 	    (struct mg_connection *)mg_calloc(1, sizeof(*conn) + MAX_REQUEST_SIZE);
 	if (conn == NULL) {