Klaus Demo nginx / d90282d
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files Igor Sysoev 17 years ago
216 changed file(s) with 1102 addition(s) and 1157 deletion(s). Raw diff Collapse all Expand all
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGINX_H_INCLUDED_
17 #define _NGINX_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_ARRAY_H_INCLUDED_
17 #define _NGX_ARRAY_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_BUF_H_INCLUDED_
17 #define _NGX_BUF_H_INCLUDED_
28
511 #include <ngx_core.h>
612
713
8 #if 0
9 /* the buf type */
14 typedef void * ngx_buf_tag_t;
1015
11 /* the buf's content is in memory */
12 #define NGX_HUNK_IN_MEMORY 0x0001
13 /* the buf's content can be changed */
14 #define NGX_HUNK_TEMP 0x0002
15 /* the buf's content is in cache and can not be changed */
16 #define NGX_HUNK_MEMORY 0x0004
17 #define NGX_HUNK_MMAP 0x0008
18
19 /* the buf's content is recycled */
20 #define NGX_HUNK_RECYCLED 0x0010
21
22 /* the buf's content is in a file */
23 #define NGX_HUNK_FILE 0x0020
24
25 #define NGX_HUNK_STORAGE (NGX_HUNK_IN_MEMORY \
26 |NGX_HUNK_TEMP|NGX_HUNK_MEMORY|NGX_HUNK_MMAP \
27 |NGX_HUNK_RECYCLED|NGX_HUNK_FILE)
28
29 /* the buf flags */
30
31 /* in thread state flush means to write the buf completely before return */
32 /* in event state flush means to start to write the buf */
33 #define NGX_HUNK_FLUSH 0x0100
34
35 /* the last buf */
36 #define NGX_HUNK_LAST 0x0200
37
38
39 #define NGX_HUNK_PREREAD 0x2000
40 #define NGX_HUNK_LAST_SHADOW 0x4000
41 #define NGX_HUNK_TEMP_FILE 0x8000
42 #endif
43
44
45 typedef void * ngx_buf_tag_t;
46
47 typedef struct ngx_buf_s ngx_buf_t;
16 typedef struct ngx_buf_s ngx_buf_t;
4817
4918 struct ngx_buf_s {
5019 u_char *pos;
6029 ngx_buf_t *shadow;
6130
6231
63 /* the buf's content can be changed */
32 /* the buf's content could be changed */
6433 unsigned temporary:1;
6534
6635 /*
6736 * the buf's content is in a memory cache or in a read only memory
68 * and can not be changed
37 * and must not be changed
6938 */
7039 unsigned memory:1;
7140
72 /* the buf's content is mmap()ed and can not be changed */
41 /* the buf's content is mmap()ed and must not be changed */
7342 unsigned mmap:1;
43
7444 unsigned recycled:1;
7545 unsigned in_file:1;
7646 unsigned flush:1;
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_CONF_FILE_H_INCLUDED_
17 #define _NGX_HTTP_CONF_FILE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_CONFIG_H_INCLUDED_
17 #define _NGX_CONFIG_H_INCLUDED_
28
115121 #define INET_ADDRSTRLEN 16
116122 #endif
117123
124 #define NGX_MAXHOSTNAMELEN 64
125 /*
126 #define NGX_MAXHOSTNAMELEN MAXHOSTNAMELEN
127 */
128
118129
119130 #endif /* _NGX_CONFIG_H_INCLUDED_ */
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_CONNECTION_H_INCLUDED_
17 #define _NGX_CONNECTION_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_CORE_H_INCLUDED_
17 #define _NGX_CORE_H_INCLUDED_
28
6975 #define CRLF "\x0d\x0a"
7076
7177
72
73 #define NGX_MAXHOSTNAMELEN 64
74 /*
75 #define NGX_MAXHOSTNAMELEN MAXHOSTNAMELEN
76 */
77
78
7978 #endif /* _NGX_CORE_H_INCLUDED_ */
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_CRC_H_INCLUDED_
17 #define _NGX_CRC_H_INCLUDED_
28
814 uint32_t sum;
915
1016 for (sum = 0; len; len--) {
17
1118 /*
1219 * gcc 2.95.2 x86 and icc 7.1.006 compile that operator
13 * into the single rol opcode.
20 * into the single "rol" opcode.
1421 * msvc 6.0sp2 compiles it into four opcodes.
1522 */
1623 sum = sum >> 1 | sum << 31;
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_CYCLE_H_INCLUDED_
17 #define _NGX_CYCLE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_FILE_H_INCLUDED_
17 #define _NGX_FILE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_GARBAGE_COLLECTOR_H_INCLUDED_
17 #define _NGX_GARBAGE_COLLECTOR_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06
17 #include <ngx_config.h>
28 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_INET_H_INCLUDED_
17 #define _NGX_INET_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_LIST_H_INCLUDED_
17 #define _NGX_LIST_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_LOG_H_INCLUDED_
17 #define _NGX_LOG_H_INCLUDED_
28
2329 #define NGX_LOG_DEBUG_IMAP 0x200
2430
2531 /*
26 * after the adding a new debug level do not forget to update
27 * debug_levels[] in src/core/ngx_log.c
32 * do not forget to update debug_levels[] in src/core/ngx_log.c
33 * after the adding a new debug level
2834 */
2935
3036 #define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG_CORE
3137 #define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_IMAP
3238 #define NGX_LOG_DEBUG_CONNECTION 0x80000000
3339 #define NGX_LOG_DEBUG_ALL 0x7ffffff0
34
35
36 /*
37 "[%time] [%level] %pid#%tid: %message:(%errno)%errstr, while %action"
38 " %peer and while processing %context"
39
40 ----
41 message = "recv() failed";
42 errno = 32;
43 action = "reading request headers from client";
44 peer = "192.168.1.1";
45 context = "URL /"
46
47 "[2002/08/20 12:00:00] [error] 412#3: recv() failed (32: Broken pipe)"
48 " while reading request headers from client 192.168.1.1"
49 " and while processing URL /"
50
51 ----
52 message = "recv() failed";
53 errno = 32;
54 ngx_http_proxy_error_context_t:
55 action = "reading headers from server %s for client %s and "
56 "while processing %s"
57 backend = "127.0.0.1";
58 peer = "192.168.1.1";
59 context = "URL /"
60
61 "[2002/08/20 12:00:00] [error] 412#3: recv() failed (32: Broken pipe)"
62 " while reading headers from backend 127.0.0.1"
63 " for client 192.168.1.1 and while processing URL /"
64
65 ----
66 "[alert] 412#3: ngx_alloc: malloc() 102400 bytes failed (12: Cannot "
67 "allocate memory) while reading request headers from client 192.168.1.1"
68 " and while processing URL /"
69
70
71 OLD:
72 "... while ", action = "reading client request headers"
73 "... while reading client request headers"
74 "... while ", action = "reading client request headers"
75 context: pop3 user account
76 "... while reading client command for 'john_doe'"
77 */
7840
7941
8042 typedef size_t (*ngx_log_handler_pt) (void *ctx, char *buf, size_t len);
8749 ngx_log_handler_pt handler;
8850 };
8951
90 #define MAX_ERROR_STR 2048
52 #define MAX_ERROR_STR 2048
9153
9254
9355 /*********************************/
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_PALLOC_H_INCLUDED_
17 #define _NGX_PALLOC_H_INCLUDED_
28
713
814 /*
915 * NGX_MAX_ALLOC_FROM_POOL should be (ngx_page_size - 1), i.e. 4095 on x86.
10 * On FreeBSD 5.x it allows to use zero copy send.
16 * On FreeBSD 5.x it allows to use the zero copy sending.
1117 * On Windows NT it decreases a number of locked pages in a kernel.
1218 */
1319 #define NGX_MAX_ALLOC_FROM_POOL (ngx_pagesize - 1)
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_PARSE_H_INCLUDED_
17 #define _NGX_PARSE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_RADIX_TREE_H_INCLUDED_
17 #define _NGX_RADIX_TREE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_RBTREE_H_INCLUDED_
17 #define _NGX_RBTREE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_REGEX_H_INCLUDED_
17 #define _NGX_REGEX_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16
27 void *ngx_slab_alloc(ngx_slab_pool_t *pool, size_t size)
38 {
4
5
69 return NULL;
710 }
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_SLAB_H_INCLUDED_
17 #define _NGX_SLAB_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_STRING_H_INCLUDED_
17 #define _NGX_STRING_H_INCLUDED_
28
1824 #if (WIN32)
1925
2026 #define ngx_strncasecmp(s1, s2, n) \
21 strnicmp((const char *) s1, (const char *) s2, n)
27 strnicmp((const char *) s1, (const char *) s2, n)
2228 #define ngx_strcasecmp(s1, s2) \
23 stricmp((const char *) s1, (const char *) s2)
29 stricmp((const char *) s1, (const char *) s2)
2430
25 #define ngx_snprintf _snprintf
26 #define ngx_vsnprintf _vsnprintf
31 #define ngx_snprintf _snprintf
32 #define ngx_vsnprintf _vsnprintf
2733
2834 #else
2935
3036 #define ngx_strncasecmp(s1, s2, n) \
31 strncasecmp((const char *) s1, (const char *) s2, n)
37 strncasecmp((const char *) s1, (const char *) s2, n)
3238 #define ngx_strcasecmp(s1, s2) \
33 strcasecmp((const char *) s1, (const char *) s2)
39 strcasecmp((const char *) s1, (const char *) s2)
3440
35 #define ngx_snprintf snprintf
36 #define ngx_vsnprintf vsnprintf
41 #define ngx_snprintf snprintf
42 #define ngx_vsnprintf vsnprintf
3743
3844 #endif
3945
4046
4147 #define ngx_strncmp(s1, s2, n) \
42 strncmp((const char *) s1, (const char *) s2, n)
48 strncmp((const char *) s1, (const char *) s2, n)
4349
4450 /* msvc and icc compile strcmp() to inline loop */
45 #define ngx_strcmp(s1, s2) strcmp((const char *) s1, (const char *) s2)
51 #define ngx_strcmp(s1, s2) strcmp((const char *) s1, (const char *) s2)
4652
47 #define ngx_strstr(s1, s2) strstr((const char *) s1, (const char *) s2)
48 #define ngx_strlen(s) strlen((const char *) s)
53 #define ngx_strstr(s1, s2) strstr((const char *) s1, (const char *) s2)
54 #define ngx_strlen(s) strlen((const char *) s)
4955
5056 /*
51 * msvc and icc compile memset() to inline "rep stos"
52 * while ZeroMemory and bzero are calls.
53 *
54 * icc can also inline mov's of a zeroed register for small blocks.
57 * msvc and icc compile memset() to the inline "rep stos"
58 * while ZeroMemory() and bzero() are the calls.
59 * icc may also inline several mov's of a zeroed register for small blocks.
5560 */
5661 #define ngx_memzero(buf, n) memset(buf, 0, n)
5762
58 /* msvc and icc compile memcpy() to inline "rep movs" */
63 /* msvc and icc compile memcpy() to the inline "rep movs" */
5964 #define ngx_memcpy(dst, src, n) memcpy(dst, src, n)
6065 #define ngx_cpymem(dst, src, n) ((u_char *) memcpy(dst, src, n)) + n
6166
62 /* msvc and icc compile memcmp() to inline loop */
67 /* msvc and icc compile memcmp() to the inline loop */
6368 #define ngx_memcmp memcmp
6469
6570 u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n);
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_TABLE_H_INCLUDED_
17 #define _NGX_TABLE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
1116
1217
1318 /*
14 * In the threaded mode only one thread updates cached time and strings
19 * In the threaded mode only one thread updates the cached time and strings
1520 * and these operations are protected by the mutex. The reading of the cached
1621 * time and strings is not protected by the mutex. To avoid the race
1722 * conditions for non-atomic values we use the NGX_TIME_SLOTS slots to store
289294 mon += 2;
290295
291296 if (yday >= 306) {
297
292298 /*
293299 * there is no "yday" in Win32 SYSTEMTIME
294300 *
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_TIMES_H_INCLUDED_
17 #define _NGX_TIMES_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_AIO_MODULE_H_INCLUDED_
17 #define _NGX_AIO_MODULE_H_INCLUDED_
28
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_IOCP_MODULE_H_INCLUDED_
17 #define _NGX_IOCP_MODULE_H_INCLUDED_
28
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_KQUEUE_MODULE_H_INCLUDED_
17 #define _NGX_KQUEUE_MODULE_H_INCLUDED_
28
+0
-41
src/event/modules/ngx_overlapped_module.c less more
0
1
2 event = WSACreateEvent(void);
3 WSAEventSelect(s, event, FD_ACCEPT);
4
5
6 int ngx_overlapped_process_events(ngx_log_t *log)
7 {
8 if (acceptex)
9 n = SleepEx(timer, 1);
10 else
11 n = WSAWaitForMultipleEvents(nevents, events, 0, timer, 1);
12
13 if (n == WSA_WAIT_TIMEOUT)
14 close some event;
15
16 if (n == WSA_IO_COMPLETION)
17 again
18
19 /* try it with AcceptEx() on NT to detect connected sockets */
20 if (!acceptex) {
21 WSAEnumNetworkEvents(
22 sockets[n - WSA_WAIT_EVENT_0],
23 events[n - WSA_WAIT_EVENT_0],
24 net_events);
25
26 if (net_events.lNetworkEvents & FD_ACCEPT) {
27 if (net_events.iErrorCode[FD_ACCEPT_BIT] != 0)
28 accept error
29 again
30
31 ngx_event_accept(); OR post AcceptEx();
32 }
33 }
34 }
35
36 void CALLBACK overlapped_completion_procedure(DWORD error, DWORD nbytes,
37 LPWSAOVERLAPPED overlapped, DWORD flags)
38 {
39 run event handler
40 }
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_EVENT_H_INCLUDED_
17 #define _NGX_EVENT_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
+0
-113
src/event/ngx_event_aio_read.c less more
0
1 #include <ngx_config.h>
2 #include <ngx_core.h>
3 #include <ngx_errno.h>
4 #include <ngx_log.h>
5 #include <ngx_recv.h>
6 #include <ngx_connection.h>
7 #include <ngx_event.h>
8
9 #if (HAVE_KQUEUE)
10 #include <ngx_kqueue_module.h>
11 #endif
12
13
14 /*
15 The data is ready - 3 syscalls:
16 aio_read(), aio_error(), aio_return()
17 The data is not ready - 4 (kqueue) or 5 syscalls:
18 aio_read(), aio_error(), notifiction,
19 aio_error(), aio_return()
20 aio_cancel(), aio_error()
21 */
22
23 ssize_t ngx_event_aio_read(ngx_connection_t *c, char *buf, size_t size)
24 {
25 int rc, first, canceled;
26 ngx_event_t *ev;
27
28 ev = c->read;
29
30 canceled = 0;
31
32 if (ev->timedout) {
33 ngx_set_socket_errno(NGX_ETIMEDOUT);
34 ngx_log_error(NGX_LOG_ERR, ev->log, 0, "aio_read() timed out");
35
36 rc = aio_cancel(c->fd, &ev->aiocb);
37 if (rc == -1) {
38 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_errno,
39 "aio_cancel() failed");
40 return NGX_ERROR;
41 }
42
43 ngx_log_debug(ev->log, "aio_cancel: %d" _ rc);
44
45 canceled = 1;
46
47 ev->ready = 1;
48 }
49
50 first = 0;
51
52 if (!ev->ready) {
53 ngx_memzero(&ev->aiocb, sizeof(struct aiocb));
54
55 ev->aiocb.aio_fildes = c->fd;
56 ev->aiocb.aio_buf = buf;
57 ev->aiocb.aio_nbytes = size;
58
59 #if (HAVE_KQUEUE)
60 ev->aiocb.aio_sigevent.sigev_notify_kqueue = kq;
61 ev->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
62 ev->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev;
63 #endif
64
65 if (aio_read(&ev->aiocb) == -1) {
66 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_errno,
67 "aio_read() failed");
68 return NGX_ERROR;
69 }
70
71 ngx_log_debug(ev->log, "aio_read: OK");
72
73 ev->active = 1;
74 first = 1;
75 }
76
77 ev->ready = 0;
78
79 rc = aio_error(&ev->aiocb);
80 if (rc == -1) {
81 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_errno, "aio_error() failed");
82 return NGX_ERROR;
83 }
84
85 if (rc != 0) {
86 if (rc == NGX_EINPROGRESS) {
87 if (!first) {
88 ngx_log_error(NGX_LOG_CRIT, ev->log, rc,
89 "aio_read() still in progress");
90 }
91 return NGX_AGAIN;
92 }
93
94 if (rc == NGX_ECANCELED && canceled) {
95 return NGX_ERROR;
96 }
97
98 ngx_log_error(NGX_LOG_CRIT, ev->log, rc, "aio_read() failed");
99 return NGX_ERROR;
100 }
101
102 rc = aio_return(&ev->aiocb);
103 if (rc == -1) {
104 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_errno, "aio_return() failed");
105
106 return NGX_ERROR;
107 }
108
109 ngx_log_debug(ev->log, "aio_read: %d" _ rc);
110
111 return rc;
112 }
+0
-116
src/event/ngx_event_aio_write.c less more
0
1 #include <ngx_config.h>
2 #include <ngx_core.h>
3 #include <ngx_errno.h>
4 #include <ngx_log.h>
5 #include <ngx_recv.h>
6 #include <ngx_connection.h>
7 #include <ngx_event.h>
8
9 #if (HAVE_KQUEUE)
10 #include <ngx_kqueue_module.h>
11 #endif
12
13
14 /*
15 The data is ready - 3 syscalls:
16 aio_write(), aio_error(), aio_return()
17 The data is not ready - 4 (kqueue) or 5 syscalls:
18 aio_write(), aio_error(), notifiction,
19 aio_error(), aio_return()
20 aio_cancel(), aio_error()
21 */
22
23 ssize_t ngx_event_aio_write(ngx_connection_t *c, char *buf, size_t size)
24 {
25 int rc, first, canceled;
26 ngx_event_t *ev;
27
28 ev = c->write;
29
30 canceled = 0;
31
32 ngx_log_debug(ev->log, "aio: ev->ready: %d" _ ev->ready);
33 ngx_log_debug(ev->log, "aio: aiocb: %08x" _ &ev->aiocb);
34
35 if (ev->timedout) {
36 ngx_set_socket_errno(NGX_ETIMEDOUT);
37 ngx_log_error(NGX_LOG_ERR, ev->log, 0, "aio_write() timed out");
38
39 rc = aio_cancel(c->fd, &ev->aiocb);
40 if (rc == -1) {
41 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_errno,
42 "aio_cancel() failed");
43 return NGX_ERROR;
44 }
45
46 ngx_log_debug(ev->log, "aio_cancel: %d" _ rc);
47
48 canceled = 1;
49
50 ev->ready = 1;
51 }
52
53 first = 0;
54
55 if (!ev->ready) {
56 ngx_memzero(&ev->aiocb, sizeof(struct aiocb));
57
58 ev->aiocb.aio_fildes = c->fd;
59 ev->aiocb.aio_buf = buf;
60 ev->aiocb.aio_nbytes = size;
61
62 #if (HAVE_KQUEUE)
63 ev->aiocb.aio_sigevent.sigev_notify_kqueue = kq;
64 ev->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
65 ev->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev;
66 #endif
67
68 if (aio_write(&ev->aiocb) == -1) {
69 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_errno,
70 "aio_write() failed");
71 return NGX_ERROR;
72 }
73
74 ngx_log_debug(ev->log, "aio_write: OK");
75
76 ev->active = 1;
77 first = 1;
78 }
79
80 ev->ready = 0;
81
82 rc = aio_error(&ev->aiocb);
83 if (rc == -1) {
84 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_errno, "aio_error() failed");
85 return NGX_ERROR;
86 }
87
88 if (rc != 0) {
89 if (rc == NGX_EINPROGRESS) {
90 if (!first) {
91 ngx_log_error(NGX_LOG_CRIT, ev->log, rc,
92 "aio_write() still in progress");
93 }
94 return NGX_AGAIN;
95 }
96
97 if (rc == NGX_ECANCELED && canceled) {
98 return NGX_ERROR;
99 }
100
101 ngx_log_error(NGX_LOG_CRIT, ev->log, rc, "aio_write() failed");
102 return NGX_ERROR;
103 }
104
105 rc = aio_return(&ev->aiocb);
106 if (rc == -1) {
107 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_errno, "aio_return() failed");
108
109 return NGX_ERROR;
110 }
111
112 ngx_log_debug(ev->log, "aio_write: %d" _ rc);
113
114 return rc;
115 }
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_EVENT_BUSY_LOCK_H_INCLUDED_
17 #define _NGX_EVENT_BUSY_LOCK_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_EVENT_CONNECT_H_INCLUDED_
17 #define _NGX_EVENT_CONNECT_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_EVENT_OPENSSL_H_INCLUDED_
17 #define _NGX_EVENT_OPENSSL_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
655660 #if 0
656661 b->type &= ~(NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY|NGX_HUNK_RECYCLED);
657662 #endif
658 b->temporary = 0;
659 b->recycled = 0;
663 b->in_file = 0;
664 b->temp_file = 0;
665 b->flush = 0;
666 b->zerocopy_busy = 0;
667 b->last_shadow = 0;
668
660669 b->shadow = NULL;
661670 b = next;
662671 }
668677 |NGX_HUNK_LAST_SHADOW);
669678 #endif
670679
671 b->temporary = 0;
672 b->recycled = 0;
673 b->last_shadow = 0;
680 b->in_file = 0;
681 b->temp_file = 0;
682 b->flush = 0;
683 b->zerocopy_busy = 0;
674684
675685 b->shadow = NULL;
676686
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_EVENT_PIPE_H_INCLUDED_
17 #define _NGX_EVENT_PIPE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_EVENT_POSTED_H_INCLUDED_
17 #define _NGX_EVENT_POSTED_H_INCLUDED_
28
+0
-147
src/event/ngx_event_recv.c less more
0
1 #include <ngx_config.h>
2 #include <ngx_core.h>
3 #include <ngx_errno.h>
4 #include <ngx_log.h>
5 #include <ngx_recv.h>
6 #include <ngx_connection.h>
7
8 ssize_t ngx_event_recv_core(ngx_connection_t *c, char *buf, size_t size)
9 {
10 ssize_t n;
11 ngx_err_t err;
12 ngx_event_t *ev;
13
14 ev = c->read;
15
16 /* DEBUG */
17 #if (HAVE_KQUEUE)
18 if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
19 ngx_log_debug(c->log, "ngx_event_recv: eof:%d, avail:%d, err:%d" _
20 ev->eof _ ev->available _ ev->error);
21 }
22 #endif
23
24 #if (USE_KQUEUE)
25
26 if (ev->eof && ev->available == 0) {
27
28 if (ev->error == 0) {
29 return 0;
30 }
31
32 ngx_set_socket_errno(ev->error);
33 err = ev->error;
34 n = -1;
35
36 } else {
37 n = ngx_recv(c->fd, buf, size, 0);
38
39 if (n == -1) {
40 err = ngx_socket_errno;
41 }
42 }
43
44 if (n == -1) {
45 ev->ready = 0;
46
47 if (err == NGX_ECONNRESET && ev->ignore_econnreset) {
48 return 0;
49 }
50
51 if (err == NGX_EAGAIN) {
52 ngx_log_error(NGX_LOG_INFO, c->log, err, "recv() returned EAGAIN");
53 return NGX_AGAIN;
54 }
55
56 ngx_log_error(NGX_LOG_ERR, c->log, err, "recv() failed");
57 return NGX_ERROR;
58 }
59
60 ev->available -= n;
61 if (ev->available == 0) {
62 ev->ready = 0;
63 }
64
65 return n;
66
67 #elif (HAVE_KQUEUE)
68
69 if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)
70 && ev->eof && ev->available == 0) {
71
72 if (ev->error == 0) {
73 return 0;
74 }
75
76 ngx_set_socket_errno(ev->error);
77 err = ev->error;
78 n = -1;
79
80 } else {
81 n = ngx_recv(c->fd, buf, size, 0);
82 ngx_log_debug(c->log, "ngx_event_recv: read:%d:%d" _ n _ size);
83
84 if (n == -1) {
85 err = ngx_socket_errno;
86 }
87 }
88
89 if (n == -1) {
90 ev->ready = 0;
91
92 if (err == NGX_ECONNRESET && ev->ignore_econnreset) {
93 return 0;
94 }
95
96 if (err == NGX_EAGAIN) {
97 ngx_log_error(NGX_LOG_INFO, c->log, err, "recv() returned EAGAIN");
98 return NGX_AGAIN;
99 }
100
101 ngx_log_error(NGX_LOG_ERR, c->log, err, "recv() failed");
102 return NGX_ERROR;
103 }
104
105 if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
106 ev->available -= n;
107 if (ev->available == 0) {
108 ev->ready = 0;
109 }
110
111 } else if ((size_t) n < size) {
112 ev->ready = 0;
113 }
114
115 return n;
116
117 #else /* not kqueue */
118
119 n = ngx_recv(c->fd, buf, size, 0);
120
121 if (n == -1) {
122 err = ngx_socket_errno;
123
124 ev->ready = 0;
125
126 if (err == NGX_ECONNRESET && ev->ignore_econnreset) {
127 return 0;
128 }
129
130 if (err == NGX_EAGAIN) {
131 ngx_log_error(NGX_LOG_INFO, c->log, err, "recv() returned EAGAIN");
132 return NGX_AGAIN;
133 }
134
135 ngx_log_error(NGX_LOG_ERR, c->log, err, "recv() failed");
136 return NGX_ERROR;
137 }
138
139 if ((size_t) n < size) {
140 ev->ready = 0;
141 }
142
143 return n;
144
145 #endif
146 }
+0
-129
src/event/ngx_event_thread.c less more
0
1 volitile int ngx_last_posted_event;
2
3
4 typedef struct {
5 ngx_tid_t tid;
6 ngx_cv_t cv;
7 } ngx_thread_data_t;
8
9 static ngx_thread_data_t *threead_data;
10
11
12
13
14
15 {
16
17 err = ngx_thread_cond_wait(ngx_thread_data_cv, ngx_thread_data_mutex);
18
19 tid = ngx_thread_self();
20
21 for (i = 0; i < thread_data_n; i++) {
22 if (thread_data[i].tid == tid) {
23 cv = thread_data[i].cv;
24 break;
25 }
26 }
27
28 if (i == thread_data_n) {
29 error
30 return
31 }
32
33
34 for ( ;; ) {
35
36 err = ngx_thread_cond_wait(cv, ngx_posted_events_mutex);
37 if (err) {
38 ngx_log_error(NGX_ALERT, log, err,
39 ngx_thread_cond_wait_n " failed, thread is exiting");
40 return;
41 }
42
43 for ( ;; ) {
44 ev = NULL;
45
46 for (i = ngx_last_posted_event; i > 0; i--) {
47 ev = ngx_posted_events[i];
48
49 if (ev == NULL) {
50 continue;
51 }
52
53 err = ngx_thread_mutex_trylock(ev->mutex);
54
55 if (err == 0) {
56 ngx_posted_events[i] = NULL;
57
58 while (ngx_posted_events[ngx_last_posted_event] == NULL) {
59 ngx_last_posted_event--;
60 }
61
62 break;
63 }
64
65 if (err == NGX_EBUSY) {
66 ev = NULL;
67 continue;
68 }
69
70 ngx_log_error(NGX_ALERT, log, err,
71 ngx_thread_mutex_unlock_n " failed,
72 thread is exiting");
73
74 ngx_worker_thread_error();
75 return;
76 }
77
78 err = ngx_thread_mutex_unlock(ngx_posted_events_mutex);
79 if (err) {
80 ngx_log_error(NGX_ALERT, log, err,
81 ngx_thread_mutex_unlock_n
82 " failed, thread exiting");
83 return;
84 }
85
86 if (ev == NULL) {
87 break;
88 }
89
90 ngx_event_handle_event(ev);
91
92 err = ngx_thread_mutex_unlock(ev->mutex);
93 if (err) {
94 ngx_log_error(NGX_ALERT, log, err,
95 ngx_thread_mutex_unlock_n
96 " failed, thread exiting");
97
98 ngx_worker_thread_error();
99 return;
100 }
101
102 err = ngx_thread_mutex_lock(ngx_posted_events_mutex);
103 if (err) {
104 ngx_log_error(NGX_ALERT, log, err,
105 ngx_thread_mutex_lock_n
106 " failed, thread exiting");
107 return;
108 }
109 }
110
111 if (restart) {
112 ngx_log_error(NGX_INFO, log, 0, "thread is exiting");
113 return;
114 }
115 }
116 }
117
118 ngx_worker_thread_error()
119 {
120 ngx_err_t err;
121
122 err = ngx_thread_mutex_unlock(ngx_posted_events_mutex);
123 if (err) {
124 ngx_log_error(NGX_ALERT, log, err,
125 ngx_thread_mutex_unlock_n
126 " failed, thread exiting");
127 }
128 }
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_EVENT_TIMER_H_INCLUDED_
17 #define _NGX_EVENT_TIMER_H_INCLUDED_
28
+0
-97
src/event/ngx_event_wsarecv.c less more
0
1 #include <ngx_config.h>
2
3 #include <ngx_core.h>
4 #include <ngx_errno.h>
5 #include <ngx_log.h>
6 #include <ngx_connection.h>
7 #include <ngx_event.h>
8
9
10 ssize_t ngx_event_wsarecv(ngx_connection_t *c, char *buf, size_t size)
11 {
12 int rc;
13 u_int flags;
14 size_t bytes;
15 ngx_err_t err;
16 WSABUF wsabuf[1];
17 ngx_event_t *ev;
18 LPWSAOVERLAPPED_COMPLETION_ROUTINE handler;
19
20 ev = c->read;
21
22 /* DEBUG */ bytes = 0;
23
24 if (ev->timedout) {
25 ngx_set_socket_errno(NGX_ETIMEDOUT);
26 ngx_log_error(NGX_LOG_ERR, ev->log, 0, "WSARecv() timed out");
27
28 return NGX_ERROR;
29 }
30
31 if (ev->ready) {
32 ev->ready = 0;
33
34 #if (HAVE_IOCP) /* iocp */
35
36 if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) {
37 if (ev->ovlp.error) {
38 ngx_log_error(NGX_LOG_ERR, c->log, ev->ovlp.error,
39 "WSARecv() failed");
40 return NGX_ERROR;
41 }
42
43 return ev->available;
44 }
45
46 #endif
47
48 if (WSAGetOverlappedResult(c->fd, (LPWSAOVERLAPPED) &ev->ovlp,
49 &bytes, 0, NULL) == 0) {
50 err = ngx_socket_errno;
51 ngx_log_error(NGX_LOG_CRIT, ev->log, err,
52 "WSARecv() or WSAGetOverlappedResult() failed");
53
54 return NGX_ERROR;
55 }
56
57 return bytes;
58 }
59
60 ngx_memzero(&ev->ovlp, sizeof(WSAOVERLAPPED));
61 wsabuf[0].buf = buf;
62 wsabuf[0].len = size;
63 flags = 0;
64
65 #if 0
66 handler = ev->handler;
67 #else
68 handler = NULL;
69 #endif
70
71 rc = WSARecv(c->fd, wsabuf, 1, &bytes, &flags,
72 (LPWSAOVERLAPPED) &ev->ovlp, handler);
73
74 ngx_log_debug(ev->log, "WSARecv: %d:%d" _ rc _ bytes);
75
76 if (rc == -1) {
77 err = ngx_socket_errno;
78 if (err == WSA_IO_PENDING) {
79 return NGX_AGAIN;
80
81 } else {
82 ngx_log_error(NGX_LOG_CRIT, ev->log, err, "WSARecv() failed");
83 return NGX_ERROR;
84 }
85 }
86
87 #if (HAVE_IOCP) /* iocp */
88
89 if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) {
90 return NGX_AGAIN;
91 }
92
93 #endif
94
95 return bytes;
96 }
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_SSL_H_INCLUDED_
17 #define _NGX_HTTP_SSL_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_PROXY_HANDLER_H_INCLUDED_
17 #define _NGX_HTTP_PROXY_HANDLER_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_H_INCLUDED_
17 #define _NGX_HTTP_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_BUSY_LOCK_H_INCLUDED_
17 #define _NGX_HTTP_BUSY_LOCK_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_CACHE_H_INCLUDED_
17 #define _NGX_HTTP_CACHE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_CONFIG_H_INCLUDED_
17 #define _NGX_HTTP_CONFIG_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_CORE_H_INCLUDED_
17 #define _NGX_HTTP_CORE_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_LOG_HANDLER_H_INCLUDED_
17 #define _NGX_HTTP_LOG_HANDLER_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
3843 while (p < b->last && state < sw_done) {
3944 ch = *p++;
4045
41 /* gcc 2.95.2 and vc 6.0 compile this switch as an jump table */
46 /* gcc 2.95.2 and msvc 6.0 compile this switch as an jump table */
4247
4348 switch (state) {
4449
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_REQUEST_H_INCLUDED_
17 #define _NGX_HTTP_REQUEST_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_HTTP_SCRIPT_H_INCLUDED_
17 #define _NGX_HTTP_SCRIPT_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_IMAP_H_INCLUDED_
17 #define _NGX_IMAP_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_AIO_H_INCLUDED_
17 #define _NGX_AIO_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_ALLOC_H_INCLUDED_
17 #define _NGX_ALLOC_H_INCLUDED_
28
1521 * Linux has memalign() or posix_memalign()
1622 * Solaris has memalign()
1723 * FreeBSD has not memalign() or posix_memalign() but its malloc() alignes
18 * allocations bigger than page size at page boundary.
24 * allocations bigger than page size at the page boundary.
1925 */
2026
2127 #if (HAVE_POSIX_MEMALIGN || HAVE_MEMALIGN)
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_ATOMIC_H_INCLUDED_
17 #define _NGX_ATOMIC_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_CHANNEL_H_INCLUDED_
17 #define _NGX_CHANNEL_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #include <ngx_config.h>
17 #include <ngx_core.h>
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_ERRNO_H_INCLUDED_
17 #define _NGX_ERRNO_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_FILES_H_INCLUDED_
17 #define _NGX_FILES_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_FREEBSD_H_INCLUDED_
17 #define _NGX_FREEBSD_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_FREEBSD_CONFIG_H_INCLUDED_
17 #define _NGX_FREEBSD_CONFIG_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
38
49
5 /* FreeBSD 3.4 at least */
10 /* FreeBSD 3.0 at least */
611 char ngx_freebsd_kern_ostype[20];
712 char ngx_freebsd_kern_osrelease[20];
813 int ngx_freebsd_kern_osreldate;
914 int ngx_freebsd_hw_ncpu;
15 int ngx_freebsd_net_inet_tcp_sendspace;
16
17 /* FreeBSD 4.9 */
1018 int ngx_freebsd_machdep_hlt_logical_cpus;
11 int ngx_freebsd_net_inet_tcp_sendspace;
19
20 /* FreeBSD 5.0 */
21 int ngx_freebsd_kern_ipc_zero_copy_send;
22
23
1224 int ngx_freebsd_sendfile_nbytes_bug;
1325 int ngx_freebsd_use_tcp_nopush;
14
15 /* FreeBSD 5.0 */
16 int ngx_freebsd_kern_ipc_zero_copy_send;
1726
1827
1928 ngx_os_io_t ngx_os_io = {
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_FREEBSD_RFORK_THREAD_H_INCLUDED_
17 #define _NGX_FREEBSD_RFORK_THREAD_H_INCLUDED_
28
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_LINUX_H_INCLUDED_
17 #define _NGX_LINUX_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_LINUX_CONFIG_H_INCLUDED_
17 #define _NGX_LINUX_CONFIG_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_OS_H_INCLUDED_
17 #define _NGX_OS_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_POSIX_CONFIG_H_INCLUDED_
17 #define _NGX_POSIX_CONFIG_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_PROCESS_H_INCLUDED_
17 #define _NGX_PROCESS_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_PROCESS_CYCLE_H_INCLUDED_
17 #define _NGX_PROCESS_CYCLE_H_INCLUDED_
28
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
+0
-28
src/os/unix/ngx_sendv.c less more
0
1 #include <ngx_core.h>
2 #include <ngx_types.h>
3 #include <ngx_errno.h>
4 #include <ngx_connection.h>
5 #include <ngx_log.h>
6 #include <ngx_sendv.h>
7
8 ssize_t ngx_sendv(ngx_connection_t *c, ngx_iovec_t *iovec, int n)
9 {
10 ssize_t rc;
11 ngx_err_t err;
12
13 rc = writev(c->fd, iovec, n);
14
15 if (rc == -1) {
16 err = ngx_socket_errno;
17 if (err == NGX_EAGAIN) {
18 ngx_log_error(NGX_LOG_INFO, c->log, err, "sendv() eagain");
19 return NGX_AGAIN;
20 }
21
22 ngx_log_error(NGX_LOG_ERR, c->log, err, "sendv() failed");
23 return NGX_ERROR;
24 }
25
26 return rc;
27 }
+0
-15
src/os/unix/ngx_sendv.h less more
0 #ifndef _NGX_SENDV_H_INCLUDED_
1 #define _NGX_SENDV_H_INCLUDED_
2
3
4 #include <ngx_types.h>
5 #include <ngx_connection.h>
6
7 typedef struct iovec ngx_iovec_t;
8 #define ngx_iov_base iov_base
9 #define ngx_iov_len iov_len
10
11 ssize_t ngx_sendv(ngx_connection_t *c, ngx_iovec_t *iovec, int n);
12
13
14 #endif /* _NGX_SENDV_H_INCLUDED_ */
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_SHARED_H_INCLUDED_
17 #define _NGX_SHARED_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
510 /*
611 * ioctl(FIONBIO) sets a blocking mode with the single syscall
712 * while fcntl(F_SETFL, ~O_NONBLOCK) needs to learn before
8 * a previous state using fcntl(F_GETFL).
13 * the previous state using fcntl(F_GETFL).
914 *
1015 * ioctl() and fcntl() are syscalls on at least FreeBSD 2.x, Linux 2.2
1116 * and Solaris 7.
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_SOCKET_H_INCLUDED_
17 #define _NGX_SOCKET_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_SOLARIS_H_INCLUDED_
17 #define _NGX_SOLARIS_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_SOLARIS_CONFIG_H_INCLUDED_
17 #define _NGX_SOLARIS_CONFIG_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
00
11 /*
2 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
2 * Copyright (C) 2002-2004 Igor Sysoev
33 */
44
55
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_THREAD_H_INCLUDED_
17 #define _NGX_THREAD_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_TIME_H_INCLUDED_
17 #define _NGX_TIME_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_TYPES_H_INCLUDED_
17 #define _NGX_TYPES_H_INCLUDED_
28
+0
-34
src/os/unix/ngx_unix_init.c less more
0
1 #include <ngx_config.h>
2 #include <ngx_core.h>
3
4
5 #if 0
6 /* STUB */
7 ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size);
8 ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in);
9 int ngx_posix_init(ngx_log_t *log);
10 int ngx_posix_post_conf_init(ngx_log_t *log);
11 /* */
12 #endif
13
14
15 ngx_os_io_t ngx_os_io = {
16 ngx_unix_recv,
17 ngx_readv_chain,
18 NULL,
19 ngx_writev_chain,
20 NGX_HAVE_ZEROCOPY
21 };
22
23
24 int ngx_os_init(ngx_log_t *log)
25 {
26 return ngx_posix_init(log);
27 }
28
29
30 int ngx_os_post_conf_init(ngx_log_t *log)
31 {
32 return ngx_posix_post_conf_init(log);
33 }
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_USER_H_INCLUDED_
17 #define _NGX_USER_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
+0
-30
src/os/unix/ngx_x86_mutex.h less more
0
1
2 typedef struct {
3 int lock;
4 } ngx_mutex_t;
5
6
7 static inline int ngx_spin_lock(ngx_mutex_t *m, int count)
8 {
9 int lock;
10
11 __asm__ __volatile("
12
13 get_lock:
14 mov $1, %1
15 xchg %1, %2
16 cmp $0, %1
17 jne spin_lock
18
19 spin_lock:
20 cmp $0, %3
21 je failed
22
23 dec %3
24 rep nop
25 cmp $0, %2
26 jne spin_lock
27
28 ": "=q" (lock), "m" (m->lock), "q" (count));
29 }
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06
17 #include <sys/syscall.h>
28 #include <machine/asm.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_ALLOC_H_INCLUDED_
17 #define _NGX_ALLOC_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_ATOMIC_H_INCLUDED_
17 #define _NGX_ATOMIC_H_INCLUDED_
28
00
11 /*
2 TODO:
3 add WSA error messages for NT and 98
4 test for English only messages
5 */
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
6 /*
7 * TODO:
8 * add WSA error messages for NT and 98
9 * test for English only messages
10 */
611
712 #include <ngx_config.h>
813 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_ERRNO_H_INCLUDED_
17 #define _NGX_ERRNO_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_FILES_H_INCLUDED_
17 #define _NGX_FILES_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_OS_H_INCLUDED_
17 #define _NGX_OS_H_INCLUDED_
28
+0
-26
src/os/win32/ngx_os_thread.c less more
0
1
2 #include <ngx_config.h>
3
4 #include <ngx_log.h>
5 #include <ngx_os_thread.h>
6
7
8 int ngx_create_os_thread(ngx_os_tid_t *tid, void *stack,
9 ngx_thread_start_routine_t func, void *arg,
10 ngx_log_t log)
11 {
12 ngx_os_tid_t id;
13 int dummy; /* needed in Win9X only, in NT can be NULL */
14
15 id = CreateThread(NULL, stack_size, func, arg, 0, &dummy);
16
17 if (id == NULL) {
18 ngx_log_error(NGX_LOG_ERR, log, err, "CreateThread() failed");
19 return NGX_ERROR;
20 }
21
22 *tid = id;
23
24 return NGX_OK;
25 }
+0
-14
src/os/win32/ngx_os_thread.h less more
0 #ifndef _NGX_OS_THREAD_H_INCLUDED_
1 #define _NGX_OS_THREAD_H_INCLUDED_
2
3
4 #include <ngx_config.h>
5
6
7 typedef HANDLE ngx_os_tid_t;
8 typedef int ngx_tid_t;
9
10 typedef LPTHREAD_START_ROUTINE ngx_thread_start_routine_t
11
12
13 #endif /* _NGX_OS_THREAD_H_INCLUDED_ */
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_PROCESS_H_INCLUDED_
17 #define _NGX_PROCESS_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_PROCESS_CYCLE_H_INCLUDED_
17 #define _NGX_PROCESS_CYCLE_H_INCLUDED_
28
+0
-10
src/os/win32/ngx_recv.h less more
0 #ifndef _NGX_RECV_H_INCLUDED_
1 #define _NGX_RECV_H_INCLUDED_
2
3
4 #include <errno.h>
5
6 #define ngx_recv(fd, buf, size, flags) recv(fd, buf, size, flags)
7
8
9 #endif /* _NGX_RECV_H_INCLUDED_ */
+0
-145
src/os/win32/ngx_sendfile.c less more
0
1 #include <ngx_config.h>
2 #include <ngx_core.h>
3 #include <ngx_types.h>
4 #include <ngx_files.h>
5 #include <ngx_socket.h>
6 #include <ngx_errno.h>
7 #include <ngx_log.h>
8 #include <ngx_connection.h>
9 #include <ngx_sendv.h>
10 #include <ngx_sendfile.h>
11
12 /*
13 TODO:
14 various flags
15 TransmitPackets
16 */
17
18 #if (HAVE_WIN32_TRANSMITFILE)
19
20 int ngx_sendfile(ngx_connection_t *c,
21 ngx_iovec_t *headers, int hdr_cnt,
22 ngx_fd_t fd, off_t offset, size_t nbytes,
23 ngx_iovec_t *trailers, int trl_cnt,
24 off_t *sent, u_int flags)
25 {
26 int tfrc, rc;
27 ngx_err_t tf_err, err;
28 OVERLAPPED olp;
29 TRANSMIT_FILE_BUFFERS tfb, *ptfb;
30
31 #if 0
32 ev = c->write;
33
34 if (ev->timedout) {
35 ngx_set_socket_errno(NGX_ETIMEDOUT);
36 ngx_log_error(NGX_LOG_ERR, ev->log, 0, "TransmitFile() timed out");
37
38 return NGX_ERROR;
39 }
40
41 if (ev->ready) {
42 ev->ready = 0;
43
44 #if (HAVE_IOCP) /* iocp */
45
46 if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) {
47 if (ev->ovlp.error) {
48 ngx_log_error(NGX_LOG_ERR, ev->log, 0, "TransmitFile() failed");
49 return NGX_ERROR;
50 }
51
52 return ev->available;
53 }
54 }
55
56 #endif
57
58 /* TODO: WSAGetOverlappedResult stuff */
59
60 }
61
62 #endif
63
64
65 tf_err = 0;
66 err = 0;
67
68 olp.Internal = 0;
69 olp.InternalHigh = 0;
70 olp.Offset = (DWORD) offset;
71 olp.OffsetHigh = (DWORD) (offset >> 32);
72 olp.hEvent = NULL;
73
74 if (headers || trailers) {
75 tfb.Head = headers->ngx_iov_base;
76 tfb.HeadLength = headers->ngx_iov_len;
77 tfb.Tail = trailers->ngx_iov_base;
78 tfb.TailLength = trailers->ngx_iov_len;
79 ptfb = &tfb;
80
81 } else {
82 ptfb = NULL;
83 }
84
85 #if 1
86 flags = TF_DISCONNECT|TF_REUSE_SOCKET;
87 tfrc = transmitfile(c->fd, NULL, 0, 0, &olp, NULL, flags);
88 #else
89 tfrc = TransmitFile(c->fd, fd, nbytes, 0, &olp, ptfb, flags);
90 #endif
91
92 #if 0
93 #if 1
94 tfrc = TransmitFile(c->fd, fd, nbytes, 0, &olp, ptfb, 0);
95 #else
96 tfrc = TransmitFile(c->fd, fd, nbytes, 0, NULL, ptfb, 0);
97 #endif
98 #endif
99
100 if (tfrc == 0) {
101 tf_err = ngx_socket_errno;
102 ngx_log_error(NGX_LOG_NOTICE, c->log, tf_err,
103 "ngx_sendfile: TransmitFile failed");
104 if (tf_err == WSA_IO_PENDING) {
105 return NGX_AGAIN;
106 }
107 }
108
109 /* set sent */
110 #if 0
111 rc = WSAGetOverlappedResult(c->fd, &olp, (unsigned long *) sent, 0, NULL);
112 #else
113 *sent = olp.InternalHigh;
114 rc = 1;
115 #endif
116
117 ngx_log_debug(c->log, "TransmitFile: %d, @%I64d %I64d:%d" _
118 tfrc _ offset _ *sent _ nbytes);
119
120 if (rc == 0) {
121 err = ngx_socket_errno;
122 ngx_log_error(NGX_LOG_ERR, c->log, err,
123 "ngx_sendfile: WSAGetOverlappedResult failed");
124 }
125
126 if (tfrc == 0) {
127 if (tf_err != NGX_EAGAIN) {
128 ngx_log_error(NGX_LOG_ERR, c->log, tf_err,
129 "ngx_sendfile: TransmitFile failed");
130 return NGX_ERROR;
131 }
132
133 ngx_log_error(NGX_LOG_INFO, c->log, tf_err,
134 "ngx_sendfile: TransmitFile sent only %I64d bytes",
135 *sent);
136 }
137
138 if (rc == 0)
139 return NGX_ERROR;
140
141 return NGX_OK;
142 }
143
144 #endif
+0
-46
src/os/win32/ngx_sendv.c less more
0
1 #include <ngx_config.h>
2
3 #include <ngx_core.h>
4 #include <ngx_types.h>
5 #include <ngx_errno.h>
6 #include <ngx_connection.h>
7 #include <ngx_log.h>
8 #include <ngx_sendv.h>
9
10 #include <ngx_string.h>
11
12 ssize_t ngx_sendv(ngx_connection_t *c, ngx_iovec_t *iovec, int n)
13 {
14 int rc;
15 size_t sent;
16 ngx_err_t err;
17
18 #if 0
19 /* STUB: WSABUF must be 4-byte aligned. Undocumented WSAEINVAL error */
20 ngx_iovec_t iov[10];
21 ngx_memcpy(iov, iovec, n * sizeof(ngx_iovec_t));
22 #endif
23
24 sent = 0;
25
26 ngx_log_debug(c->log, "WSASend: %d, %d, %08x" _ c->fd _ n _ iovec);
27
28 rc = WSASend(c->fd, iovec, n, &sent, 0, NULL, NULL);
29
30 ngx_log_debug(c->log, "WSASend() done");
31
32 if (rc == SOCKET_ERROR) {
33 err = ngx_socket_errno;
34
35 if (err == NGX_EAGAIN) {
36 ngx_log_error(NGX_LOG_INFO, c->log, err, "WSASend() eagain");
37 return NGX_AGAIN;
38 }
39
40 ngx_log_error(NGX_LOG_ERR, c->log, err, "WSASend() failed");
41 return NGX_ERROR;
42 }
43
44 return sent;
45 }
+0
-15
src/os/win32/ngx_sendv.h less more
0 #ifndef _NGX_SENDV_H_INCLUDED_
1 #define _NGX_SENDV_H_INCLUDED_
2
3
4 #include <ngx_config.h>
5 #include <ngx_connection.h>
6
7 typedef WSABUF ngx_iovec_t;
8 #define ngx_iov_base buf
9 #define ngx_iov_len len
10
11 ssize_t ngx_sendv(ngx_connection_t *c, ngx_iovec_t *iovec, int n);
12
13
14 #endif /* _NGX_SENDV_H_INCLUDED_ */
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06
17 #define NGX_SERVICE_CONTROL_SHUTDOWN 128
28 #define NGX_SERVICE_CONTROL_REOPEN 129
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_SHARED_H_INCLUDED_
17 #define _NGX_SHARED_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_SOCKET_H_INCLUDED_
17 #define _NGX_SOCKET_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_THREAD_H_INCLUDED_
17 #define _NGX_THREAD_H_INCLUDED_
28
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
05
16 #include <ngx_config.h>
27 #include <ngx_core.h>
1217 /*
1318 * A file time is a 64-bit value that represents the number
1419 * of 100-nanosecond intervals that have elapsed since
15 * 12:00 A.M. January 1, 1601 (UTC).
20 * January 1, 1601 12:00 A.M. UTC.
1621 *
1722 * Between January 1, 1970 (Epoch) and January 1, 1601 there were
1823 * 134744 days,
0
1 /*
2 * Copyright (C) 2002-2004 Igor Sysoev
3 */
4
5
06 #ifndef _NGX_TIME_H_INCLUDED_
17 #define _NGX_TIME_H_INCLUDED_
28
+6
-0