Mercurial > hg > nginx-quic
annotate src/os/win32/ngx_thread.c @ 4907:01d3d3a185e9 stable-1.2
Merge of r4892: keepalive memory usage optimization.
The ngx_http_keepalive_handler() function is now trying to not
keep c->buffer's memory for idle connections.
This behaviour is consistent with the ngx_http_set_keepalive()
function and it should decrease memory usage in some cases (especially
if epoll/rtsig is used).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 13 Nov 2012 11:21:31 +0000 |
parents | 2942a827da09 |
children | 94ce52db3367 |
rev | line source |
---|---|
461 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
461 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 | |
11 | |
12 ngx_int_t ngx_threads_n; | |
13 | |
14 | |
15 static size_t stack_size; | |
16 | |
17 | |
563 | 18 ngx_err_t |
19 ngx_create_thread(ngx_tid_t *tid, | |
20 ngx_thread_value_t (__stdcall *func)(void *arg), void *arg, ngx_log_t *log) | |
461 | 21 { |
2725 | 22 u_long id; |
461 | 23 ngx_err_t err; |
24 | |
2725 | 25 *tid = CreateThread(NULL, stack_size, func, arg, 0, &id); |
461 | 26 |
27 if (*tid != NULL) { | |
2725 | 28 ngx_log_error(NGX_LOG_NOTICE, log, 0, |
29 "create thread " NGX_TID_T_FMT, id); | |
461 | 30 return 0; |
31 } | |
32 | |
33 err = ngx_errno; | |
34 ngx_log_error(NGX_LOG_ALERT, log, err, "CreateThread() failed"); | |
35 return err; | |
36 } | |
37 | |
38 | |
563 | 39 ngx_int_t |
40 ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle) | |
461 | 41 { |
42 stack_size = size; | |
43 | |
44 return NGX_OK; | |
45 } | |
46 | |
47 | |
563 | 48 ngx_err_t |
49 ngx_thread_key_create(ngx_tls_key_t *key) | |
461 | 50 { |
51 *key = TlsAlloc(); | |
52 | |
53 if (*key == TLS_OUT_OF_INDEXES) { | |
54 return ngx_errno; | |
55 } | |
56 | |
57 return 0; | |
58 } | |
59 | |
60 | |
563 | 61 ngx_err_t |
62 ngx_thread_set_tls(ngx_tls_key_t *key, void *data) | |
461 | 63 { |
64 if (TlsSetValue(*key, data) == 0) { | |
65 return ngx_errno; | |
66 } | |
67 | |
68 return 0; | |
69 } | |
70 | |
71 | |
563 | 72 ngx_mutex_t * |
73 ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags) | |
461 | 74 { |
4571
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
75 ngx_mutex_t *m; |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
76 |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
77 m = ngx_alloc(sizeof(ngx_mutex_t), log); |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
78 if (m == NULL) { |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
79 return NULL; |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
80 } |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
81 |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
82 m->log = log; |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
83 |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
84 /* STUB */ |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
85 |
2942a827da09
Win32: improved ngx_mutex_init() stub (ticket #138).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
86 return m; |
461 | 87 } |
501 | 88 |
89 | |
90 /* STUB */ | |
91 | |
563 | 92 void |
501 | 93 ngx_mutex_lock(ngx_mutex_t *m) { |
563 | 94 return; |
501 | 95 } |
96 | |
97 | |
563 | 98 |
501 | 99 ngx_int_t |
100 ngx_mutex_trylock(ngx_mutex_t *m) { | |
101 return NGX_OK; | |
102 } | |
103 | |
563 | 104 |
105 void | |
106 ngx_mutex_unlock(ngx_mutex_t *m) { | |
107 return; | |
108 } | |
109 | |
501 | 110 /**/ |