*_param_adapter: Distinguish between network error and remote hard close

This commit is contained in:
Evgeny Grin (Karlson2k)
2017-08-27 21:53:37 +03:00
parent de5c159df5
commit 1d3131799b
3 changed files with 11 additions and 6 deletions
+6 -2
View File
@@ -152,8 +152,10 @@ recv_param_adapter (struct MHD_Connection *connection,
}
if (MHD_SCKT_ERR_IS_EINTR_ (err))
return MHD_ERR_AGAIN_;
if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_))
return MHD_ERR_CONNRESET_;
/* Treat any other error as hard error. */
return MHD_ERR_CONNRESET_;
return MHD_ERR_NOTCONN_;
}
#ifdef EPOLL_SUPPORT
else if (i > (size_t)ret)
@@ -204,8 +206,10 @@ send_param_adapter (struct MHD_Connection *connection,
}
if (MHD_SCKT_ERR_IS_EINTR_ (err))
return MHD_ERR_AGAIN_;
if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_))
return MHD_ERR_CONNRESET_;
/* Treat any other error as hard error. */
return MHD_ERR_CONNRESET_;
return MHD_ERR_NOTCONN_;
}
#ifdef EPOLL_SUPPORT
else if (i > (size_t)ret)
+3 -2
View File
@@ -36,12 +36,13 @@
#define MHD_ERR_AGAIN_ (-3073)
/**
* "Connection (remote) reset" error code
* Connection was hard-closed by remote peer.
*/
#define MHD_ERR_CONNRESET_ (-3074)
/**
* "Not connected" error code
* Connection is not connected anymore due to
* network error or any other reason.
*/
#define MHD_ERR_NOTCONN_ (-3075)
+2 -2
View File
@@ -73,7 +73,7 @@ recv_tls_adapter (struct MHD_Connection *connection,
/* Likely 'GNUTLS_E_INVALID_SESSION' (client communication
disrupted); interpret as a hard error */
connection->tls_read_ready = false;
return MHD_ERR_CONNRESET_;
return MHD_ERR_NOTCONN_;
}
#ifdef EPOLL_SUPPORT
@@ -125,7 +125,7 @@ send_tls_adapter (struct MHD_Connection *connection,
{
/* Likely 'GNUTLS_E_INVALID_SESSION' (client communication
disrupted); interpret as a hard error */
return MHD_ERR_CONNRESET_;
return MHD_ERR_NOTCONN_;
}
#ifdef EPOLL_SUPPORT
/* If NOT all available data was sent - socket is not write ready anymore. */