Mercurial > hg > nginx-quic
annotate src/os/win32/ngx_time.c @ 8910:f3510cb959d1
Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367).
When reading exactly rev->available bytes, rev->available might become 0
after FIONREAD usage introduction in efd71d49bde0. On the next call of
ngx_readv_chain() on systems with EPOLLRDHUP this resulted in return without
any actions, that is, with rev->ready set, and this in turn resulted in no
timers set in event pipe, leading to socket leaks.
Fix is to reset rev->ready in ngx_readv_chain() when returning due to
rev->available being 0 with EPOLLRDHUP, much like it is already done in
ngx_unix_recv(). This ensures that if rev->available will become 0, on
systems with EPOLLRDHUP support appropriate EPOLLRDHUP-specific handling
will happen on the next ngx_readv_chain() call.
While here, also synced ngx_readv_chain() to match ngx_unix_recv() and
reset rev->ready when returning due to rev->available being 0 with kqueue.
This is mostly cosmetic change, as rev->ready is anyway reset when
rev->available is set to 0.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 15 Jul 2022 15:19:32 +0300 |
parents | f95de1361039 |
children |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
6 |
179
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
563 | 12 void |
13 ngx_gettimeofday(struct timeval *tp) | |
179
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 { |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 uint64_t intervals; |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 FILETIME ft; |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
17 |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
18 GetSystemTimeAsFileTime(&ft); |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 /* |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 * A file time is a 64-bit value that represents the number |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 * of 100-nanosecond intervals that have elapsed since |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
23 * January 1, 1601 12:00 A.M. UTC. |
179
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 * |
181
811bdd2af794
nginx-0.0.1-2003-11-12-20:25:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
180
diff
changeset
|
25 * Between January 1, 1970 (Epoch) and January 1, 1601 there were |
7279
f95de1361039
Win32: fixed comment in ngx_gettimeofday() calculations.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
26 * 134774 days, |
179
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 * 11644473600 seconds or |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 * 11644473600,000,000,0 100-nanosecond intervals. |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
29 * |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
30 * See also MSKB Q167296. |
179
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 */ |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 intervals = ((uint64_t) ft.dwHighDateTime << 32) | ft.dwLowDateTime; |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 intervals -= 116444736000000000; |
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 |
180
2d143372a1ee
nginx-0.0.1-2003-11-12-01:16:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
179
diff
changeset
|
36 tp->tv_sec = (long) (intervals / 10000000); |
2d143372a1ee
nginx-0.0.1-2003-11-12-01:16:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
179
diff
changeset
|
37 tp->tv_usec = (long) ((intervals % 10000000) / 10); |
179
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 } |
324
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
39 |
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
40 |
563 | 41 void |
42 ngx_libc_localtime(time_t s, struct tm *tm) | |
509 | 43 { |
44 struct tm *t; | |
45 | |
563 | 46 t = localtime(&s); |
509 | 47 *tm = *t; |
48 } | |
49 | |
50 | |
563 | 51 void |
52 ngx_libc_gmtime(time_t s, struct tm *tm) | |
509 | 53 { |
54 struct tm *t; | |
55 | |
563 | 56 t = gmtime(&s); |
509 | 57 *tm = *t; |
58 } | |
59 | |
60 | |
563 | 61 ngx_int_t |
62 ngx_gettimezone(void) | |
324
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
63 { |
2724 | 64 u_long n; |
324
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
65 TIME_ZONE_INFORMATION tz; |
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
66 |
2724 | 67 n = GetTimeZoneInformation(&tz); |
68 | |
69 switch (n) { | |
70 | |
71 case TIME_ZONE_ID_UNKNOWN: | |
324
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
72 return -tz.Bias; |
2724 | 73 |
74 case TIME_ZONE_ID_STANDARD: | |
75 return -(tz.Bias + tz.StandardBias); | |
76 | |
77 case TIME_ZONE_ID_DAYLIGHT: | |
78 return -(tz.Bias + tz.DaylightBias); | |
79 | |
80 default: /* TIME_ZONE_ID_INVALID */ | |
81 return 0; | |
324
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
82 } |
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
83 } |