comparison src/core/ngx_shmtx.c @ 160:73e8476f9142 NGINX_0_3_27

nginx 0.3.27 *) Change: the "variables_hash_max_size" and "variables_hash_bucket_size" directives. *) Feature: the $body_bytes_sent variable can be used not only in the "log_format" directive. *) Feature: the $ssl_protocol and $ssl_cipher variables. *) Feature: the cache line size detection for widespread CPUs at start time. *) Feature: now the "accept_mutex" directive is supported using fcntl(2) on platforms different from i386, amd64, sparc64, and ppc. *) Feature: the "lock_file" directive and the --with-lock-path=PATH autoconfiguration directive. *) Bugfix: if the HTTPS protocol was used in the "proxy_pass" directive then the requests with the body was not transferred.
author Igor Sysoev <http://sysoev.ru>
date Wed, 08 Feb 2006 00:00:00 +0300
parents
children 6ae1357b7b7c
comparison
equal deleted inserted replaced
159:25c27e983933 160:73e8476f9142
1
2 /*
3 * Copyright (C) Igor Sysoev
4 */
5
6
7 #include <ngx_config.h>
8 #include <ngx_core.h>
9
10
11 #if (NGX_HAVE_ATOMIC_OPS)
12
13
14 ngx_int_t
15 ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name, ngx_log_t *log)
16 {
17 mtx->lock = addr;
18
19 return NGX_OK;
20 }
21
22 #else
23
24
25 ngx_int_t
26 ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name, ngx_log_t *log)
27 {
28 if (mtx->name) {
29
30 if (ngx_strcmp(name, mtx->name) == 0) {
31 mtx->name = name;
32 mtx->log = log;
33
34 return NGX_OK;
35 }
36
37 ngx_shmtx_destory(mtx);
38 }
39
40 mtx->fd = ngx_open_file(name, NGX_FILE_RDWR, NGX_FILE_CREATE_OR_OPEN);
41
42 if (mtx->fd == NGX_INVALID_FILE) {
43 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
44 ngx_open_file_n " \"%s\" failed", name);
45 return NGX_ERROR;
46 }
47
48 if (ngx_delete_file(name) == NGX_FILE_ERROR) {
49 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
50 ngx_delete_file_n " \"%s\" failed", name);
51 }
52
53 mtx->name = name;
54 mtx->log = log;
55
56 return NGX_OK;
57 }
58
59
60 void
61 ngx_shmtx_destory(ngx_shmtx_t *mtx)
62 {
63 if (ngx_close_file(mtx->fd) == NGX_FILE_ERROR) {
64 ngx_log_error(NGX_LOG_ALERT, mtx->log, ngx_errno,
65 ngx_close_file_n " \"%s\" failed", mtx->name);
66 }
67 }
68
69
70 #endif