diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-08-24 17:43:32 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-08-24 17:43:32 +0300 |
commit | b84aa64dcbfb92d31cef10f2f45025a67f2418e4 (patch) | |
tree | bd7509540538801bdde233b24c0a130fbd6d757a /src | |
parent | 8b4b52ae3b3c9400b3d7040a591203a0c1b74ec3 (diff) | |
download | unit-b84aa64dcbfb92d31cef10f2f45025a67f2418e4.tar.gz unit-b84aa64dcbfb92d31cef10f2f45025a67f2418e4.tar.bz2 |
Removed configure option --no-threads.
Diffstat (limited to 'src')
-rw-r--r-- | src/nxt_conn.h | 7 | ||||
-rw-r--r-- | src/nxt_event_conn_job_sendfile.c | 4 | ||||
-rw-r--r-- | src/nxt_event_engine.c | 20 | ||||
-rw-r--r-- | src/nxt_job.c | 18 | ||||
-rw-r--r-- | src/nxt_job.h | 2 | ||||
-rw-r--r-- | src/nxt_job_file_cache.c | 5 | ||||
-rw-r--r-- | src/nxt_lib.c | 2 | ||||
-rw-r--r-- | src/nxt_main.h | 4 | ||||
-rw-r--r-- | src/nxt_runtime.c | 38 | ||||
-rw-r--r-- | src/nxt_runtime.h | 4 | ||||
-rw-r--r-- | src/nxt_signal.c | 40 | ||||
-rw-r--r-- | src/nxt_signal.h | 20 | ||||
-rw-r--r-- | src/nxt_spinlock.h | 23 | ||||
-rw-r--r-- | src/nxt_thread.h | 24 | ||||
-rw-r--r-- | src/nxt_thread_id.h | 16 | ||||
-rw-r--r-- | src/nxt_thread_time.c | 40 | ||||
-rw-r--r-- | src/nxt_thread_time.h | 6 | ||||
-rw-r--r-- | src/nxt_unix.h | 4 |
18 files changed, 8 insertions, 269 deletions
diff --git a/src/nxt_conn.h b/src/nxt_conn.h index 0062158e..33c6ad28 100644 --- a/src/nxt_conn.h +++ b/src/nxt_conn.h @@ -143,20 +143,13 @@ struct nxt_conn_s { nxt_queue_t requests; /* of nxt_req_conn_link_t */ -#if (NXT_SSLTLS || NXT_THREADS) - /* SunC does not support "zero-sized struct/union". */ - union { #if (NXT_SSLTLS) void *ssltls; #endif -#if (NXT_THREADS) nxt_thread_pool_t *thread_pool; -#endif } u; -#endif - nxt_mp_t *mem_pool; nxt_task_t task; diff --git a/src/nxt_event_conn_job_sendfile.c b/src/nxt_event_conn_job_sendfile.c index 15d7fe1d..80a292a0 100644 --- a/src/nxt_event_conn_job_sendfile.c +++ b/src/nxt_event_conn_job_sendfile.c @@ -7,8 +7,6 @@ #include <nxt_main.h> -#if (NXT_THREADS) - typedef struct { nxt_job_t job; nxt_buf_t *out; @@ -257,5 +255,3 @@ nxt_event_conn_job_sendfile_completion(nxt_task_t *task, nxt_conn_t *c, return b; } - -#endif diff --git a/src/nxt_event_engine.c b/src/nxt_event_engine.c index 2ec7df1e..bdb0a011 100644 --- a/src/nxt_event_engine.c +++ b/src/nxt_event_engine.c @@ -124,14 +124,6 @@ nxt_event_engine_create(nxt_task_t *task, nxt_queue_init(&engine->listen_connections); nxt_queue_init(&engine->idle_connections); -#if !(NXT_THREADS) - - if (interface->signal_support) { - thread->time.signal = -1; - } - -#endif - return engine; timers_fail: @@ -160,16 +152,6 @@ nxt_event_engine_post_init(nxt_event_engine_t *engine) return engine->event.enable_post(engine, nxt_event_engine_post_handler); } -#if !(NXT_THREADS) - - /* Only signals may are posted in single-threaded mode. */ - - if (engine->event->signal_support) { - return NXT_OK; - } - -#endif - if (nxt_event_engine_signal_pipe_create(engine) != NXT_OK) { return NXT_ERROR; } @@ -426,13 +408,11 @@ nxt_event_engine_change(nxt_event_engine_t *engine, return nxt_event_engine_signals_start(engine); } -#if (NXT_THREADS) /* * Reset the PID flag to start the signal thread if * some future event facility will not support signals. */ engine->signals->process = 0; -#endif } return NXT_OK; diff --git a/src/nxt_job.c b/src/nxt_job.c index 1e08cc26..995fd89b 100644 --- a/src/nxt_job.c +++ b/src/nxt_job.c @@ -7,11 +7,9 @@ #include <nxt_main.h> -#if (NXT_THREADS) static void nxt_job_thread_trampoline(nxt_task_t *task, void *obj, void *data); static void nxt_job_thread_return_handler(nxt_task_t *task, void *obj, void *data); -#endif void * @@ -110,8 +108,6 @@ nxt_job_start(nxt_task_t *task, nxt_job_t *job, nxt_work_handler_t handler) { nxt_debug(task, "%s start", job->name); -#if (NXT_THREADS) - if (job->thread_pool != NULL) { nxt_int_t ret; @@ -129,14 +125,10 @@ nxt_job_start(nxt_task_t *task, nxt_job_t *job, nxt_work_handler_t handler) handler = job->abort_handler; } -#endif - handler(job->task, job, job->data); } -#if (NXT_THREADS) - /* A trampoline function is called by a thread pool thread. */ static void @@ -158,16 +150,12 @@ nxt_job_thread_trampoline(nxt_task_t *task, void *obj, void *data) } } -#endif - void nxt_job_return(nxt_task_t *task, nxt_job_t *job, nxt_work_handler_t handler) { nxt_debug(task, "%s return", job->name); -#if (NXT_THREADS) - if (job->engine != NULL) { /* A return function is called in thread pool thread context. */ @@ -179,8 +167,6 @@ nxt_job_return(nxt_task_t *task, nxt_job_t *job, nxt_work_handler_t handler) return; } -#endif - if (nxt_slow_path(job->cancel)) { nxt_debug(task, "%s cancellation", job->name); handler = job->abort_handler; @@ -191,8 +177,6 @@ nxt_job_return(nxt_task_t *task, nxt_job_t *job, nxt_work_handler_t handler) } -#if (NXT_THREADS) - static void nxt_job_thread_return_handler(nxt_task_t *task, void *obj, void *data) { @@ -211,5 +195,3 @@ nxt_job_thread_return_handler(nxt_task_t *task, void *obj, void *data) handler(job->task, job, job->data); } - -#endif diff --git a/src/nxt_job.h b/src/nxt_job.h index 9445f17d..d308c35d 100644 --- a/src/nxt_job.h +++ b/src/nxt_job.h @@ -43,11 +43,9 @@ typedef struct { nxt_mp_t *mem_pool; nxt_queue_link_t link; -#if (NXT_THREADS) nxt_thread_pool_t *thread_pool; nxt_event_engine_t *engine; nxt_log_t *log; -#endif nxt_work_t work; diff --git a/src/nxt_job_file_cache.c b/src/nxt_job_file_cache.c index 47468dc2..680d0665 100644 --- a/src/nxt_job_file_cache.c +++ b/src/nxt_job_file_cache.c @@ -33,14 +33,9 @@ nxt_job_file_cache_read(nxt_cache_t *cache, nxt_job_file_t *jbf) return; } -#if (NXT_THREADS) - if (node->accessed + 60 > nxt_thread_time()) { jbf->job.thread_pool = NULL; } - -#endif - } nxt_job_file_read(jbf); diff --git a/src/nxt_lib.c b/src/nxt_lib.c index d5daa6e8..32bd0eff 100644 --- a/src/nxt_lib.c +++ b/src/nxt_lib.c @@ -124,7 +124,7 @@ nxt_lib_stop(void) { /* TODO: stop engines */ -#if (NXT_THREADS0) +#if 0 for ( ;; ) { nxt_thread_pool_t *tp; diff --git a/src/nxt_main.h b/src/nxt_main.h index 128647eb..b8ebfc93 100644 --- a/src/nxt_main.h +++ b/src/nxt_main.h @@ -87,9 +87,7 @@ typedef struct { #include <nxt_mem_zone.h> #include <nxt_signal.h> -#if (NXT_THREADS) #include <nxt_semaphore.h> -#endif #include <nxt_djb_hash.h> #include <nxt_murmur_hash.h> @@ -131,9 +129,7 @@ nxt_thread_extern_data(nxt_thread_t, nxt_thread_context); #include <nxt_port.h> #include <nxt_port_memory.h> #include <nxt_port_rpc.h> -#if (NXT_THREADS) #include <nxt_thread_pool.h> -#endif typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr, nxt_conn_t *c); diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c index fcae4ed8..5fa4443d 100644 --- a/src/nxt_runtime.c +++ b/src/nxt_runtime.c @@ -42,12 +42,11 @@ static nxt_int_t nxt_runtime_log_files_create(nxt_task_t *task, nxt_runtime_t *rt); static nxt_int_t nxt_runtime_pid_file_create(nxt_task_t *task, nxt_file_name_t *pid_file); - -#if (NXT_THREADS) static void nxt_runtime_thread_pool_destroy(nxt_task_t *task, nxt_runtime_t *rt, nxt_runtime_cont_t cont); -#endif - +static void nxt_runtime_thread_pool_init(void); +static void nxt_runtime_thread_pool_exit(nxt_task_t *task, void *obj, + void *data); static void nxt_runtime_process_destroy(nxt_runtime_t *rt, nxt_process_t *process); static nxt_process_t *nxt_runtime_process_remove_pid(nxt_runtime_t *rt, @@ -314,7 +313,6 @@ nxt_runtime_event_engines(nxt_task_t *task, nxt_runtime_t *rt) static nxt_int_t nxt_runtime_thread_pools(nxt_thread_t *thr, nxt_runtime_t *rt) { -#if (NXT_THREADS) nxt_int_t ret; nxt_array_t *thread_pools; @@ -332,8 +330,6 @@ nxt_runtime_thread_pools(nxt_thread_t *thr, nxt_runtime_t *rt) return NXT_ERROR; } -#endif - return NXT_OK; } @@ -358,8 +354,6 @@ nxt_runtime_start(nxt_task_t *task, void *obj, void *data) goto fail; } -#if (NXT_THREADS) - /* * Thread pools should be destroyed before starting worker * processes, because thread pool semaphores will stick in @@ -367,12 +361,6 @@ nxt_runtime_start(nxt_task_t *task, void *obj, void *data) */ nxt_runtime_thread_pool_destroy(task, rt, rt->start); -#else - - rt->start(task->thread, rt); - -#endif - return; fail: @@ -446,7 +434,6 @@ fail: static void nxt_single_process_start(nxt_thread_t *thr, nxt_task_t *task, nxt_runtime_t *rt) { -#if (NXT_THREADS) nxt_int_t ret; ret = nxt_runtime_thread_pool_create(thr, rt, rt->auxiliary_threads, @@ -457,8 +444,6 @@ nxt_single_process_start(nxt_thread_t *thr, nxt_task_t *task, nxt_runtime_t *rt) return; } -#endif - rt->types |= (1U << NXT_PROCESS_SINGLE); nxt_runtime_listen_sockets_enable(task, rt); @@ -484,15 +469,11 @@ nxt_runtime_quit(nxt_task_t *task) if (!engine->shutdown) { engine->shutdown = 1; -#if (NXT_THREADS) - if (!nxt_array_is_empty(rt->thread_pools)) { nxt_runtime_thread_pool_destroy(task, rt, nxt_runtime_quit); done = 0; } -#endif - if (nxt_runtime_is_master(rt)) { nxt_master_stop_worker_processes(task, rt); done = 0; @@ -544,16 +525,12 @@ nxt_runtime_exit(nxt_task_t *task, void *obj, void *data) rt = obj; engine = data; -#if (NXT_THREADS) - nxt_debug(task, "thread pools: %d", rt->thread_pools->nelts); if (!nxt_array_is_empty(rt->thread_pools)) { return; } -#endif - if (nxt_runtime_is_master(rt)) { if (rt->pid_file != NULL) { nxt_file_delete(rt->pid_file); @@ -619,13 +596,6 @@ nxt_runtime_event_engine_free(nxt_runtime_t *rt) } -#if (NXT_THREADS) - -static void nxt_runtime_thread_pool_init(void); -static void nxt_runtime_thread_pool_exit(nxt_task_t *task, void *obj, - void *data); - - nxt_int_t nxt_runtime_thread_pool_create(nxt_thread_t *thr, nxt_runtime_t *rt, nxt_uint_t max_threads, nxt_nsec_t timeout) @@ -723,8 +693,6 @@ nxt_runtime_thread_pool_exit(nxt_task_t *task, void *obj, void *data) } } -#endif - static nxt_int_t nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt) diff --git a/src/nxt_runtime.h b/src/nxt_runtime.h index b45b1ac3..4fa0f4f6 100644 --- a/src/nxt_runtime.h +++ b/src/nxt_runtime.h @@ -31,10 +31,8 @@ struct nxt_runtime_s { nxt_file_name_t *pid_file; -#if (NXT_THREADS) nxt_array_t *thread_pools; /* of nxt_thread_pool_t */ nxt_runtime_cont_t continuation; -#endif nxt_process_t *mprocess; size_t nprocesses; @@ -80,10 +78,8 @@ void nxt_runtime_quit(nxt_task_t *task); void nxt_runtime_event_engine_free(nxt_runtime_t *rt); -#if (NXT_THREADS) nxt_int_t nxt_runtime_thread_pool_create(nxt_thread_t *thr, nxt_runtime_t *rt, nxt_uint_t max_threads, nxt_nsec_t timeout); -#endif nxt_inline nxt_bool_t diff --git a/src/nxt_signal.c b/src/nxt_signal.c index 3ccd0774..0ab1ba99 100644 --- a/src/nxt_signal.c +++ b/src/nxt_signal.c @@ -23,6 +23,7 @@ static nxt_int_t nxt_signal_action(int signo, void (*handler)(int)); +static void nxt_signal_thread(void *data); nxt_event_signals_t * @@ -106,11 +107,6 @@ nxt_signal_handler(int signo) } -#if (NXT_THREADS) - -static void nxt_signal_thread(void *data); - - nxt_int_t nxt_signal_thread_start(nxt_event_engine_t *engine) { @@ -194,37 +190,3 @@ nxt_signal_thread_stop(nxt_event_engine_t *engine) nxt_thread_cancel(thread); nxt_thread_wait(thread); } - - -#else /* !(NXT_THREADS) */ - - -nxt_int_t -nxt_signal_handlers_start(nxt_event_engine_t *engine) -{ - const nxt_sig_event_t *sigev; - - for (sigev = engine->signals->sigev; sigev->signo != 0; sigev++) { - if (nxt_signal_action(sigev->signo, nxt_signal_handler) != NXT_OK) { - return NXT_ERROR; - } - } - - if (sigprocmask(SIG_UNBLOCK, &engine->signals->sigmask, NULL) != 0) { - nxt_main_log_alert("sigprocmask(SIG_UNBLOCK) failed %E", nxt_errno); - return NXT_ERROR; - } - - return NXT_OK; -} - - -void -nxt_signal_handlers_stop(nxt_event_engine_t *engine) -{ - if (sigprocmask(SIG_BLOCK, &engine->signals->sigmask, NULL) != 0) { - nxt_main_log_alert("sigprocmask(SIG_BLOCK) failed %E", nxt_errno); - } -} - -#endif diff --git a/src/nxt_signal.h b/src/nxt_signal.h index 2194d1f4..900a9e16 100644 --- a/src/nxt_signal.h +++ b/src/nxt_signal.h @@ -28,18 +28,14 @@ typedef struct { const nxt_sig_event_t *sigev; sigset_t sigmask; -#if (NXT_THREADS) /* Used by the signal thread. */ nxt_pid_t process; nxt_thread_handle_t thread; -#endif } nxt_event_signals_t; nxt_event_signals_t *nxt_event_engine_signals(const nxt_sig_event_t *sigev); -#if (NXT_THREADS) - #define \ nxt_event_engine_signals_start(engine) \ nxt_signal_thread_start(engine) @@ -52,21 +48,5 @@ nxt_event_engine_signals_stop(engine) \ NXT_EXPORT nxt_int_t nxt_signal_thread_start(nxt_event_engine_t *engine); NXT_EXPORT void nxt_signal_thread_stop(nxt_event_engine_t *engine); -#else /* !(NXT_THREADS) */ - -#define \ -nxt_event_engine_signals_start(engine) \ - nxt_signal_handlers_start(engine) - -#define \ -nxt_event_engine_signals_stop(engine) \ - nxt_signal_handlers_stop(engine) - - -NXT_EXPORT nxt_int_t nxt_signal_handlers_start(nxt_event_engine_t *engine); -NXT_EXPORT void nxt_signal_handlers_stop(nxt_event_engine_t *engine); - -#endif - #endif /* _NXT_SIGNAL_H_INCLUDED_ */ diff --git a/src/nxt_spinlock.h b/src/nxt_spinlock.h index bdc3a5f6..072e001d 100644 --- a/src/nxt_spinlock.h +++ b/src/nxt_spinlock.h @@ -8,8 +8,6 @@ #define _NXT_UNIX_SPINLOCK_H_INCLUDED_ -#if (NXT_THREADS) - #if (NXT_HAVE_MACOSX_SPINLOCK) #include <libkern/OSAtomic.h> @@ -33,25 +31,4 @@ NXT_EXPORT nxt_bool_t nxt_thread_spin_trylock(nxt_thread_spinlock_t *lock); NXT_EXPORT void nxt_thread_spin_unlock(nxt_thread_spinlock_t *lock); -#else /* !(NXT_THREADS) */ - - -typedef nxt_atomic_t nxt_thread_spinlock_t; - -#define \ -nxt_thread_spin_init(ncpu, count) - -#define \ -nxt_thread_spin_lock(lock) - -#define \ -nxt_thread_spin_trylock(lock) \ - 1 - -#define \ -nxt_thread_spin_unlock(lock) - -#endif - - #endif /* _NXT_UNIX_SPINLOCK_H_INCLUDED_ */ diff --git a/src/nxt_thread.h b/src/nxt_thread.h index 33314b71..4a71a5a1 100644 --- a/src/nxt_thread.h +++ b/src/nxt_thread.h @@ -8,8 +8,6 @@ #define _NXT_UNIX_THREAD_H_INCLUDED_ -#if (NXT_THREADS) - /* * Thread Specific Data * @@ -126,26 +124,6 @@ NXT_EXPORT nxt_err_t nxt_thread_cond_wait(nxt_thread_cond_t *cond, nxt_thread_mutex_t *mtx, nxt_nsec_t timeout); -#else /* !(NXT_THREADS) */ - -#define \ -nxt_thread_extern_data(type, tsd) \ - NXT_EXPORT extern type tsd - -#define \ -nxt_thread_declare_data(type, tsd) \ - type tsd - -#define \ -nxt_thread_init_data(tsd) - -#define \ -nxt_thread_get_data(tsd) \ - &tsd - -#endif /* NXT_THREADS */ - - #if (NXT_HAVE_PTHREAD_YIELD) #define \ nxt_thread_yield() \ @@ -172,10 +150,8 @@ struct nxt_thread_s { nxt_tid_t tid; nxt_thread_handle_t handle; -#if (NXT_THREADS) nxt_thread_link_t *link; nxt_thread_pool_t *thread_pool; -#endif nxt_thread_time_t time; diff --git a/src/nxt_thread_id.h b/src/nxt_thread_id.h index d083b8fc..f8a52533 100644 --- a/src/nxt_thread_id.h +++ b/src/nxt_thread_id.h @@ -8,9 +8,6 @@ #define _NXT_UNIX_THREAD_ID_H_INCLUDED_ -#if (NXT_THREADS) - - #if (NXT_LINUX) typedef pid_t nxt_tid_t; @@ -65,17 +62,4 @@ nxt_thread_handle_equal(th0, th1) \ pthread_equal(th0, th1) -#else /* !(NXT_THREADS) */ - -typedef uint32_t nxt_tid_t; -typedef uint32_t nxt_thread_handle_t; - - -#define \ -nxt_thread_tid(thr) \ - 0 - -#endif - - #endif /* _NXT_UNIX_THREAD_ID_H_INCLUDED_ */ diff --git a/src/nxt_thread_time.c b/src/nxt_thread_time.c index 95c88fa3..d084af0a 100644 --- a/src/nxt_thread_time.c +++ b/src/nxt_thread_time.c @@ -30,14 +30,8 @@ */ -#if (NXT_THREADS) static void nxt_time_thread(void *data); static void nxt_thread_time_shared(nxt_monotonic_time_t *now); - -static nxt_bool_t nxt_use_shared_time = 0; -static volatile nxt_monotonic_time_t nxt_shared_time; -#endif - static void nxt_thread_realtime_update(nxt_thread_t *thr, nxt_monotonic_time_t *now); static u_char *nxt_thread_time_string_no_cache(nxt_thread_t *thr, @@ -48,45 +42,19 @@ static nxt_time_string_cache_t *nxt_thread_time_string_cache(nxt_thread_t *thr, static nxt_atomic_int_t nxt_gmtoff; +static nxt_bool_t nxt_use_shared_time = 0; +static volatile nxt_monotonic_time_t nxt_shared_time; void nxt_thread_time_update(nxt_thread_t *thr) { -#if (NXT_THREADS) - if (nxt_use_shared_time) { nxt_thread_time_shared(&thr->time.now); } else { nxt_monotonic_time(&thr->time.now); } - -#else - - nxt_monotonic_time(&thr->time.now); - - if (thr->time.signal >= 0) { - nxt_time_t s; - - /* - * Synchronous real time update: - * single-threaded mode without signal event support. - */ - - s = nxt_thread_time(thr); - - if (thr->time.signal == 0 && thr->time.last_localtime != s) { - /* Synchronous local time update in non-signal context. */ - - nxt_localtime(s, &thr->time.localtime); - thr->time.last_localtime = s; - - nxt_gmtoff = nxt_timezone(&thr->time.localtime); - } - } - -#endif } @@ -111,8 +79,6 @@ nxt_thread_time_free(nxt_thread_t *thr) } -#if (NXT_THREADS) - void nxt_time_thread_start(nxt_msec_t interval) { @@ -207,8 +173,6 @@ nxt_thread_time_shared(nxt_monotonic_time_t *now) } } -#endif - nxt_time_t nxt_thread_time(nxt_thread_t *thr) diff --git a/src/nxt_thread_time.h b/src/nxt_thread_time.h index 126709de..05ecd938 100644 --- a/src/nxt_thread_time.h +++ b/src/nxt_thread_time.h @@ -61,17 +61,13 @@ typedef struct { } nxt_thread_time_t; -#if (NXT_THREADS) -void nxt_time_thread_start(nxt_msec_t interval); -#endif - - NXT_EXPORT void nxt_thread_time_update(nxt_thread_t *thr); void nxt_thread_time_free(nxt_thread_t *thr); NXT_EXPORT nxt_time_t nxt_thread_time(nxt_thread_t *thr); NXT_EXPORT nxt_realtime_t *nxt_thread_realtime(nxt_thread_t *thr); NXT_EXPORT u_char *nxt_thread_time_string(nxt_thread_t *thr, nxt_time_string_t *ts, u_char *buf); +void nxt_time_thread_start(nxt_msec_t interval); #define \ diff --git a/src/nxt_unix.h b/src/nxt_unix.h index 21096e31..7ab2f9da 100644 --- a/src/nxt_unix.h +++ b/src/nxt_unix.h @@ -190,11 +190,7 @@ #include <time.h> #include <ucontext.h> #include <unistd.h> - - -#if (NXT_THREADS) #include <pthread.h> -#endif #if (NXT_HAVE_EPOLL) #include <sys/epoll.h> |