Mercurial > hg > nginx-quic
annotate src/core/ngx_shmtx.c @ 1972:9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 17 Apr 2008 14:23:20 +0000 |
parents | 01884449985f |
children | 0daede16d68b |
rev | line source |
---|---|
611 | 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 | |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
611
diff
changeset
|
15 ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name) |
611 | 16 { |
17 mtx->lock = addr; | |
18 | |
19 return NGX_OK; | |
20 } | |
21 | |
22 #else | |
23 | |
24 | |
25 ngx_int_t | |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
611
diff
changeset
|
26 ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name) |
611 | 27 { |
28 if (mtx->name) { | |
29 | |
30 if (ngx_strcmp(name, mtx->name) == 0) { | |
31 mtx->name = name; | |
32 return NGX_OK; | |
33 } | |
34 | |
35 ngx_shmtx_destory(mtx); | |
36 } | |
37 | |
1100
01884449985f
fix building on platforms with non-supported atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
38 mtx->fd = ngx_open_file(name, NGX_FILE_RDWR, NGX_FILE_CREATE_OR_OPEN, |
01884449985f
fix building on platforms with non-supported atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
39 NGX_FILE_DEFAULT_ACCESS); |
611 | 40 |
41 if (mtx->fd == NGX_INVALID_FILE) { | |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
611
diff
changeset
|
42 ngx_log_error(NGX_LOG_EMERG, ngx_cycle->log, ngx_errno, |
611 | 43 ngx_open_file_n " \"%s\" failed", name); |
44 return NGX_ERROR; | |
45 } | |
46 | |
47 if (ngx_delete_file(name) == NGX_FILE_ERROR) { | |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
611
diff
changeset
|
48 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_errno, |
611 | 49 ngx_delete_file_n " \"%s\" failed", name); |
50 } | |
51 | |
52 mtx->name = name; | |
53 | |
54 return NGX_OK; | |
55 } | |
56 | |
57 | |
58 void | |
59 ngx_shmtx_destory(ngx_shmtx_t *mtx) | |
60 { | |
61 if (ngx_close_file(mtx->fd) == NGX_FILE_ERROR) { | |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
611
diff
changeset
|
62 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_errno, |
611 | 63 ngx_close_file_n " \"%s\" failed", mtx->name); |
64 } | |
65 } | |
66 | |
67 | |
68 #endif |