Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.15.12 ]​[ nginx-1.16.0 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #include <ngx_config.h>
0009 #include <ngx_core.h>
0010 
0011 
0012 ngx_int_t
0013 ngx_thread_cond_create(ngx_thread_cond_t *cond, ngx_log_t *log)
0014 {
0015     ngx_err_t  err;
0016 
0017     err = pthread_cond_init(cond, NULL);
0018     if (err == 0) {
0019         return NGX_OK;
0020     }
0021 
0022     ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_init() failed");
0023     return NGX_ERROR;
0024 }
0025 
0026 
0027 ngx_int_t
0028 ngx_thread_cond_destroy(ngx_thread_cond_t *cond, ngx_log_t *log)
0029 {
0030     ngx_err_t  err;
0031 
0032     err = pthread_cond_destroy(cond);
0033     if (err == 0) {
0034         return NGX_OK;
0035     }
0036 
0037     ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_destroy() failed");
0038     return NGX_ERROR;
0039 }
0040 
0041 
0042 ngx_int_t
0043 ngx_thread_cond_signal(ngx_thread_cond_t *cond, ngx_log_t *log)
0044 {
0045     ngx_err_t  err;
0046 
0047     err = pthread_cond_signal(cond);
0048     if (err == 0) {
0049         return NGX_OK;
0050     }
0051 
0052     ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_signal() failed");
0053     return NGX_ERROR;
0054 }
0055 
0056 
0057 ngx_int_t
0058 ngx_thread_cond_wait(ngx_thread_cond_t *cond, ngx_thread_mutex_t *mtx,
0059     ngx_log_t *log)
0060 {
0061     ngx_err_t  err;
0062 
0063     err = pthread_cond_wait(cond, mtx);
0064 
0065 #if 0
0066     ngx_time_update();
0067 #endif
0068 
0069     if (err == 0) {
0070         return NGX_OK;
0071     }
0072 
0073     ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_cond_wait() failed");
0074 
0075     return NGX_ERROR;
0076 }