diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-08-20 18:43:17 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-08-27 21:53:37 +0300 |
commit | 1d3131799b6783bce885a9290afa23996103a4f2 (patch) | |
tree | 718481eccb6811289c10c72217c46d0d8bc672fe /src | |
parent | de5c159df5d4395c6c67914c09552321b2012123 (diff) | |
download | libmicrohttpd-1d3131799b6783bce885a9290afa23996103a4f2.tar.gz libmicrohttpd-1d3131799b6783bce885a9290afa23996103a4f2.zip |
*_param_adapter: Distinguish between network error and remote hard close
Diffstat (limited to 'src')
-rw-r--r-- | src/microhttpd/connection.c | 8 | ||||
-rw-r--r-- | src/microhttpd/connection.h | 5 | ||||
-rw-r--r-- | src/microhttpd/connection_https.c | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 95823992..8fadc8d8 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -152,8 +152,10 @@ recv_param_adapter (struct MHD_Connection *connection, | |||
152 | } | 152 | } |
153 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) | 153 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) |
154 | return MHD_ERR_AGAIN_; | 154 | return MHD_ERR_AGAIN_; |
155 | if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_)) | ||
156 | return MHD_ERR_CONNRESET_; | ||
155 | /* Treat any other error as hard error. */ | 157 | /* Treat any other error as hard error. */ |
156 | return MHD_ERR_CONNRESET_; | 158 | return MHD_ERR_NOTCONN_; |
157 | } | 159 | } |
158 | #ifdef EPOLL_SUPPORT | 160 | #ifdef EPOLL_SUPPORT |
159 | else if (i > (size_t)ret) | 161 | else if (i > (size_t)ret) |
@@ -204,8 +206,10 @@ send_param_adapter (struct MHD_Connection *connection, | |||
204 | } | 206 | } |
205 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) | 207 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) |
206 | return MHD_ERR_AGAIN_; | 208 | return MHD_ERR_AGAIN_; |
209 | if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_)) | ||
210 | return MHD_ERR_CONNRESET_; | ||
207 | /* Treat any other error as hard error. */ | 211 | /* Treat any other error as hard error. */ |
208 | return MHD_ERR_CONNRESET_; | 212 | return MHD_ERR_NOTCONN_; |
209 | } | 213 | } |
210 | #ifdef EPOLL_SUPPORT | 214 | #ifdef EPOLL_SUPPORT |
211 | else if (i > (size_t)ret) | 215 | else if (i > (size_t)ret) |
diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h index f5316887..37e4d550 100644 --- a/src/microhttpd/connection.h +++ b/src/microhttpd/connection.h | |||
@@ -36,12 +36,13 @@ | |||
36 | #define MHD_ERR_AGAIN_ (-3073) | 36 | #define MHD_ERR_AGAIN_ (-3073) |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * "Connection (remote) reset" error code | 39 | * Connection was hard-closed by remote peer. |
40 | */ | 40 | */ |
41 | #define MHD_ERR_CONNRESET_ (-3074) | 41 | #define MHD_ERR_CONNRESET_ (-3074) |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * "Not connected" error code | 44 | * Connection is not connected anymore due to |
45 | * network error or any other reason. | ||
45 | */ | 46 | */ |
46 | #define MHD_ERR_NOTCONN_ (-3075) | 47 | #define MHD_ERR_NOTCONN_ (-3075) |
47 | 48 | ||
diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c index 73589b2c..03f80b8c 100644 --- a/src/microhttpd/connection_https.c +++ b/src/microhttpd/connection_https.c | |||
@@ -73,7 +73,7 @@ recv_tls_adapter (struct MHD_Connection *connection, | |||
73 | /* Likely 'GNUTLS_E_INVALID_SESSION' (client communication | 73 | /* Likely 'GNUTLS_E_INVALID_SESSION' (client communication |
74 | disrupted); interpret as a hard error */ | 74 | disrupted); interpret as a hard error */ |
75 | connection->tls_read_ready = false; | 75 | connection->tls_read_ready = false; |
76 | return MHD_ERR_CONNRESET_; | 76 | return MHD_ERR_NOTCONN_; |
77 | } | 77 | } |
78 | 78 | ||
79 | #ifdef EPOLL_SUPPORT | 79 | #ifdef EPOLL_SUPPORT |
@@ -125,7 +125,7 @@ send_tls_adapter (struct MHD_Connection *connection, | |||
125 | { | 125 | { |
126 | /* Likely 'GNUTLS_E_INVALID_SESSION' (client communication | 126 | /* Likely 'GNUTLS_E_INVALID_SESSION' (client communication |
127 | disrupted); interpret as a hard error */ | 127 | disrupted); interpret as a hard error */ |
128 | return MHD_ERR_CONNRESET_; | 128 | return MHD_ERR_NOTCONN_; |
129 | } | 129 | } |
130 | #ifdef EPOLL_SUPPORT | 130 | #ifdef EPOLL_SUPPORT |
131 | /* If NOT all available data was sent - socket is not write ready anymore. */ | 131 | /* If NOT all available data was sent - socket is not write ready anymore. */ |