diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-11-05 01:12:39 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-11-05 01:12:39 +0300 |
commit | 9cc1acef18220cfc3b66d0a761f1f7c39e0b5c29 (patch) | |
tree | 8c40a56b42bd6d0071bdd3f683cf1b520fd502a8 /src/http/ngx_http_busy_lock.c | |
parent | f60b1a5cd9f6e509caf4513f1b28ae33cb3dae4e (diff) |
nginx-0.0.1-2003-11-05-01:12:39 import
Diffstat (limited to 'src/http/ngx_http_busy_lock.c')
-rw-r--r-- | src/http/ngx_http_busy_lock.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/http/ngx_http_busy_lock.c b/src/http/ngx_http_busy_lock.c new file mode 100644 index 000000000..8ebedfb16 --- /dev/null +++ b/src/http/ngx_http_busy_lock.c @@ -0,0 +1,80 @@ + +#include <ngx_config.h> +#include <ngx_core.h> +#include <ngx_http.h> + + +char *ngx_http_set_busy_lock_slot(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf) +{ + char *p = conf; + + int i; + ngx_str_t *value; + ngx_http_busy_lock_t *bl, **blp; + + blp = (ngx_http_busy_lock_t **) (p + cmd->offset); + if (*blp) { + return "is duplicate"; + } + + /* ngx_calloc_shared() */ + if (!(bl = ngx_pcalloc(cf->pool, sizeof(ngx_http_busy_lock_t)))) { + return NGX_CONF_ERROR; + } + *blp = bl; + + value = (ngx_str_t *) cf->args->elts; + + for (i = 1; i < 3; i++) { + + if (value[i].len > 2 && ngx_strncasecmp(value[i].data, "c:", 2) == 0) { + if (bl->max_conn) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "duplicate \"%s\"", value[i].data); + return NGX_CONF_ERROR; + } + + bl->max_conn = ngx_atoi(value[i].data + 2, value[i].len - 2); + if (bl->max_conn == NGX_ERROR) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid value \"%s\"", value[i].data); + return NGX_CONF_ERROR; + } + + continue; + } + + if (value[i].len > 2 && ngx_strncasecmp(value[i].data, "w:", 2) == 0) { + if (bl->max_waiting) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "duplicate \"%s\"", value[i].data); + return NGX_CONF_ERROR; + } + + bl->max_waiting = ngx_atoi(value[i].data + 2, value[i].len - 2); + if (bl->max_waiting == NGX_ERROR) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid value \"%s\"", value[i].data); + return NGX_CONF_ERROR; + } + + continue; + } + + if (bl->timeout) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "duplicate timeout \"%s\"", value[i].data); + return NGX_CONF_ERROR; + } + + bl->timeout = ngx_parse_time(&value[1], 0); + if (bl->timeout == NGX_ERROR) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid timeout \"%s\"", value[i].data); + return NGX_CONF_ERROR; + } + } + + return NGX_CONF_OK; +} |