Mercurial > hg > nginx-quic
annotate src/os/win32/ngx_event_log.c @ 4160:88369902edb1 stable-1.0
Merging r4010, r4065:
SSL related fixes:
*) Fixing proxy_set_body and proxy_pass_request_body with SSL.
Flush flag wasn't set in constructed buffer and this prevented any data
from being actually sent to upstream due to SSL buffering. Make sure
we always set flush in the last buffer we are going to sent.
See here for report:
http://nginx.org/pipermail/nginx-ru/2011-June/041552.html
*) Proper SSL shutdown handling.
If connection has unsent alerts, SSL_shutdown() tries to send them even
if SSL_set_shutdown(SSL_RECEIVED_SHUTDOWN|SSL_SENT_SHUTDOWN) was used.
This can be prevented by SSL_set_quiet_shutdown(). SSL_set_shutdown()
is required nevertheless to preserve session.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 30 Sep 2011 13:42:59 +0000 |
parents | 6d358aeaa989 |
children | d620f497c50f |
rev | line source |
---|---|
2725 | 1 /* |
2 * Copyright (C) Igor Sysoev | |
3 */ | |
4 | |
5 | |
6 #include <ngx_config.h> | |
7 #include <ngx_core.h> | |
8 | |
9 | |
10 #define NGX_MAX_ERROR_STR 2048 | |
11 | |
12 | |
13 void ngx_cdecl | |
14 ngx_event_log(ngx_err_t err, const char *fmt, ...) | |
15 { | |
16 u_char *p, *last; | |
17 long types; | |
18 HKEY key; | |
19 HANDLE ev; | |
20 va_list args; | |
21 u_char text[NGX_MAX_ERROR_STR]; | |
22 const char *msgarg[9]; | |
23 static u_char netmsg[] = "%SystemRoot%\\System32\\netmsg.dll"; | |
24 | |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
25 last = text + NGX_MAX_ERROR_STR; |
2725 | 26 p = text + GetModuleFileName(NULL, (char *) text, NGX_MAX_ERROR_STR - 50); |
27 | |
28 *p++ = ':'; | |
29 ngx_linefeed(p); | |
30 | |
31 va_start(args, fmt); | |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
32 p = ngx_vslprintf(p, last, fmt, args); |
2725 | 33 va_end(args); |
34 | |
35 if (err) { | |
2765 | 36 p = ngx_log_errno(p, last, err); |
2725 | 37 } |
38 | |
39 if (p > last - NGX_LINEFEED_SIZE - 1) { | |
40 p = last - NGX_LINEFEED_SIZE - 1; | |
41 } | |
42 | |
43 ngx_linefeed(p); | |
44 | |
45 *p = '\0'; | |
46 | |
47 /* | |
48 * we do not log errors here since we use | |
49 * Event Log only to log our own logs open errors | |
50 */ | |
51 | |
52 if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, | |
53 "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\nginx", | |
54 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &key, NULL) | |
55 != 0) | |
56 { | |
57 return; | |
58 } | |
59 | |
60 if (RegSetValueEx(key, "EventMessageFile", 0, REG_EXPAND_SZ, | |
61 netmsg, sizeof(netmsg) - 1) | |
62 != 0) | |
63 { | |
64 return; | |
65 } | |
66 | |
67 types = EVENTLOG_ERROR_TYPE; | |
68 | |
69 if (RegSetValueEx(key, "TypesSupported", 0, REG_DWORD, | |
70 (u_char *) &types, sizeof(long)) | |
71 != 0) | |
72 { | |
73 return; | |
74 } | |
75 | |
76 RegCloseKey(key); | |
77 | |
78 ev = RegisterEventSource(NULL, "nginx"); | |
79 | |
80 msgarg[0] = (char *) text; | |
81 msgarg[1] = NULL; | |
82 msgarg[2] = NULL; | |
83 msgarg[3] = NULL; | |
84 msgarg[4] = NULL; | |
85 msgarg[5] = NULL; | |
86 msgarg[6] = NULL; | |
87 msgarg[7] = NULL; | |
88 msgarg[8] = NULL; | |
89 | |
90 /* | |
91 * the 3299 event id in netmsg.dll has the generic message format: | |
92 * "%1 %2 %3 %4 %5 %6 %7 %8 %9" | |
93 */ | |
94 | |
95 ReportEvent(ev, EVENTLOG_ERROR_TYPE, 0, 3299, NULL, 9, 0, msgarg, NULL); | |
96 | |
97 DeregisterEventSource(ev); | |
98 } |