Mercurial > hg > nginx-quic
comparison src/os/win32/ngx_errno.c @ 2740:e5a4be07c3eb
axe incomplete support of Winsock error descriptions on NT
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 22 Apr 2009 11:25:12 +0000 |
parents | 58399dcc410a |
children | 234ddbff1b2e |
comparison
equal
deleted
inserted
replaced
2739:58399dcc410a | 2740:e5a4be07c3eb |
---|---|
2 /* | 2 /* |
3 * Copyright (C) Igor Sysoev | 3 * Copyright (C) Igor Sysoev |
4 */ | 4 */ |
5 | 5 |
6 | 6 |
7 /* | |
8 * TODO: | |
9 * add WSA error messages for NT and 98 | |
10 */ | |
11 | |
12 #include <ngx_config.h> | 7 #include <ngx_config.h> |
13 #include <ngx_core.h> | 8 #include <ngx_core.h> |
14 | |
15 | |
16 static ngx_str_t wsa_errors[] = { | |
17 ngx_string("An invalid argument was supplied"), /* WSAEINVAL 10022 */ | |
18 ngx_string("Too many open sockets"), /* WSAEMFILE 10023 */ | |
19 | |
20 ngx_null_string, /* 10024 */ | |
21 ngx_null_string, /* 10025 */ | |
22 ngx_null_string, /* 10026 */ | |
23 ngx_null_string, /* 10027 */ | |
24 ngx_null_string, /* 10028 */ | |
25 ngx_null_string, /* 10029 */ | |
26 ngx_null_string, /* 10030 */ | |
27 ngx_null_string, /* 10031 */ | |
28 ngx_null_string, /* 10032 */ | |
29 ngx_null_string, /* 10033 */ | |
30 ngx_null_string, /* 10034 */ | |
31 | |
32 /* WSAEWOULDBLOCK 10035 */ | |
33 ngx_string("A non-blocking socket operation could not be completed " | |
34 "immediately"), | |
35 | |
36 ngx_null_string, /* 10036 */ | |
37 ngx_null_string, /* 10037 */ | |
38 | |
39 /* WSAENOTSOCK 10038 */ | |
40 ngx_string("An operation was attempted on something that is not a socket"), | |
41 | |
42 ngx_null_string, /* 10039 */ | |
43 ngx_null_string, /* 10040 */ | |
44 ngx_null_string, /* 10041 */ | |
45 | |
46 /* WSAENOPROTOOPT 10042 */ | |
47 ngx_string("An unknown, invalid, or unsupported option or level was " | |
48 "specified in a getsockopt or setsockopt call"), | |
49 | |
50 ngx_null_string, /* 10043 */ | |
51 ngx_null_string, /* 10044 */ | |
52 ngx_null_string, /* 10045 */ | |
53 ngx_null_string, /* 10046 */ | |
54 ngx_null_string, /* 10047 */ | |
55 ngx_null_string, /* 10048 */ | |
56 ngx_null_string, /* 10049 */ | |
57 ngx_null_string, /* 10050 */ | |
58 ngx_null_string, /* 10051 */ | |
59 ngx_null_string, /* 10052 */ | |
60 ngx_null_string, /* 10053 */ | |
61 | |
62 /* WSAECONNRESET 10054 */ | |
63 ngx_string("An existing connection was forcibly closed by the remote host"), | |
64 | |
65 /* WSAENOBUFS 10055 */ | |
66 ngx_string("An operation on a socket could not be performed because " | |
67 "the system lacked sufficient buffer space or " | |
68 "because a queue was full"), | |
69 | |
70 /* WSAEISCONN 10056 */ | |
71 ngx_string("A connect request was made on an already connected socket"), | |
72 | |
73 /* WSAENOTCONN 10057 */ | |
74 ngx_string("A request to send or receive data was disallowed because" | |
75 "the socket is not connected and (when sending on a datagram " | |
76 "socket using a sendto call) no address was supplied"), | |
77 | |
78 ngx_null_string, /* 10058 */ | |
79 ngx_null_string, /* 10059 */ | |
80 | |
81 /* WSAETIMEDOUT 10060 */ | |
82 ngx_string("A connection attempt failed because the connected party " | |
83 "did not properly respond after a period of time, " | |
84 "or established connection failed because connected host " | |
85 "has failed to respond"), | |
86 | |
87 /* WSAECONNREFUSED 10061 */ | |
88 ngx_string("No connection could be made because the target machine " | |
89 "actively refused it") | |
90 }; | |
91 | 9 |
92 | 10 |
93 u_char * | 11 u_char * |
94 ngx_strerror_r(ngx_err_t err, u_char *errstr, size_t size) | 12 ngx_strerror_r(ngx_err_t err, u_char *errstr, size_t size) |
95 { | 13 { |
96 int n; | 14 u_int len; |
97 u_int len; | |
98 ngx_err_t format_error; | |
99 | 15 |
100 if (size == 0) { | 16 if (size == 0) { |
101 return errstr; | 17 return errstr; |
102 } | 18 } |
103 | 19 |
106 NULL, err, | 22 NULL, err, |
107 MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), | 23 MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), |
108 (char *) errstr, size, NULL); | 24 (char *) errstr, size, NULL); |
109 | 25 |
110 if (len == 0) { | 26 if (len == 0) { |
111 format_error = GetLastError(); | |
112 | |
113 if (format_error == ERROR_MR_MID_NOT_FOUND) { | |
114 n = err - WSAEINVAL; | |
115 | |
116 if (n >= 0 && n <= WSAECONNREFUSED - WSAEINVAL) { | |
117 len = wsa_errors[n].len; | |
118 | |
119 if (len) { | |
120 if (len > size) { | |
121 len = size; | |
122 } | |
123 | |
124 ngx_memcpy(errstr, wsa_errors[n].data, len); | |
125 | |
126 return errstr + len; | |
127 } | |
128 } | |
129 } | |
130 | |
131 return ngx_snprintf(errstr, size, | 27 return ngx_snprintf(errstr, size, |
132 "FormatMessage() error:(%d)", format_error); | 28 "FormatMessage() error:(%d)", GetLastError()); |
133 } | 29 } |
134 | 30 |
135 /* remove ".\r\n\0" */ | 31 /* remove ".\r\n\0" */ |
136 while (errstr[len] == '\0' || errstr[len] == CR | 32 while (errstr[len] == '\0' || errstr[len] == CR |
137 || errstr[len] == LF || errstr[len] == '.') | 33 || errstr[len] == LF || errstr[len] == '.') |