Преглед на файлове

Use eventfd instead of pthread_cond (step 6/?) - test ALTERNATIVE_QUEUE in CI tests

bel преди 9 години
родител
ревизия
2ce0e7562a
променени са 1 файла, в които са добавени 7 реда и са изтрити 11 реда
  1. 7 11
      src/civetweb.c

+ 7 - 11
src/civetweb.c

@@ -20,6 +20,8 @@
  * THE SOFTWARE.
  * THE SOFTWARE.
  */
  */
 
 
+#define ALTERNATIVE_QUEUE
+
 #if defined(_WIN32)
 #if defined(_WIN32)
 #if !defined(_CRT_SECURE_NO_WARNINGS)
 #if !defined(_CRT_SECURE_NO_WARNINGS)
 #define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005 */
 #define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005 */
@@ -199,9 +201,7 @@ clock_gettime(int clk_id, struct timespec *t)
 #ifndef MAX_WORKER_THREADS
 #ifndef MAX_WORKER_THREADS
 #define MAX_WORKER_THREADS (1024 * 64)
 #define MAX_WORKER_THREADS (1024 * 64)
 #endif
 #endif
-#ifndef SOCKET_TIMEOUT_QUANTUM
-#define SOCKET_TIMEOUT_QUANTUM (10000)
-#endif
+
 
 
 mg_static_assert(MAX_WORKER_THREADS >= 1,
 mg_static_assert(MAX_WORKER_THREADS >= 1,
                  "worker threads must be a positive number");
                  "worker threads must be a positive number");
@@ -12930,13 +12930,8 @@ accept_new_connection(const struct socket *listener, struct mg_context *ctx)
 			timeout = -1;
 			timeout = -1;
 		}
 		}
 
 
-		/* Set socket timeout to the given value, but not more than a
-		 * a certain limit (SOCKET_TIMEOUT_QUANTUM, default 10 seconds),
-		 * so the server can exit after that time if requested. */
-		if ((timeout > 0) && (timeout < SOCKET_TIMEOUT_QUANTUM)) {
+		if (timeout > 0) {
 			set_sock_timeout(so.sock, timeout);
 			set_sock_timeout(so.sock, timeout);
-		} else {
-			set_sock_timeout(so.sock, SOCKET_TIMEOUT_QUANTUM);
 		}
 		}
 
 
 		produce_socket(ctx, &so);
 		produce_socket(ctx, &so);
@@ -13018,8 +13013,9 @@ master_thread_run(void *thread_func_param)
 	/* Wakeup workers that are waiting for connections to handle. */
 	/* Wakeup workers that are waiting for connections to handle. */
 	(void)pthread_mutex_lock(&ctx->thread_mutex);
 	(void)pthread_mutex_lock(&ctx->thread_mutex);
 #if defined(ALTERNATIVE_QUEUE)
 #if defined(ALTERNATIVE_QUEUE)
-/* TODO: signal all workers */
-/* TODO: close all socket handles (will avoid SOCKET_TIMEOUT_QUANTUM) */
+	for (i = 0; i < ctx->cfg_worker_threads; i++) {
+		event_signal(ctx->client_wait_events[i]);
+	}
 #else
 #else
 	pthread_cond_broadcast(&ctx->sq_full);
 	pthread_cond_broadcast(&ctx->sq_full);
 #endif
 #endif