aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_freebsd_rfork_thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix/ngx_freebsd_rfork_thread.c')
-rw-r--r--src/os/unix/ngx_freebsd_rfork_thread.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.c b/src/os/unix/ngx_freebsd_rfork_thread.c
index b64325bcd..5dfd46807 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.c
+++ b/src/os/unix/ngx_freebsd_rfork_thread.c
@@ -381,7 +381,7 @@ ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try)
return NGX_AGAIN;
}
- if (ngx_freebsd_hw_ncpu > 1 && tries++ < 1000) {
+ if (ngx_ncpu > 1 && tries++ < 1000) {
/* the spinlock is used only on the SMP system */
@@ -581,7 +581,7 @@ ngx_cond_t *ngx_cond_init(ngx_log_t *log)
}
cv->signo = NGX_CV_SIGNAL;
- cv->tid = 0;
+ cv->tid = -1;
cv->log = log;
cv->kq = -1;
@@ -640,6 +640,8 @@ ngx_int_t ngx_cond_wait(ngx_cond_t *cv, ngx_mutex_t *m)
ngx_log_error(NGX_LOG_ALERT, cv->log, ngx_errno, "kevent() failed");
return NGX_ERROR;
}
+
+ cv->tid = ngx_thread_self();
}
if (ngx_mutex_unlock(m) == NGX_ERROR) {
@@ -714,6 +716,10 @@ ngx_int_t ngx_cond_signal(ngx_cond_t *cv)
"cv %p to signal %P %d",
cv, cv->tid, cv->signo);
+ if (cv->tid == -1) {
+ return NGX_OK;
+ }
+
if (kill(cv->tid, cv->signo) == -1) {
err = ngx_errno;