Parcourir la source

Rename close_socket_gracefully to drain_and_close_socket

'gracefully' already means something specific in this codebase: whether
to send a TLS close_notify before closing (shutdown_ssl's
shutdown_gracefully param, ClientImpl::disconnect(gracefully),
tls::shutdown(session, graceful)). Reusing the word for an unrelated
TCP-level drain-before-close made the new function read as part of that
TLS machinery when it isn't. Rename it to describe what it does instead,
matching the existing close_socket/shutdown_socket and
WebSocketClient::shutdown_and_close naming.
yhirose il y a 4 jours
Parent
commit
f978bb5ca1
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      httplib.h

+ 2 - 2
httplib.h

@@ -6326,7 +6326,7 @@ inline int shutdown_socket(socket_t sock) noexcept {
 // (or bytes arriving after the receive side is closed) makes the stack send
 // (or bytes arriving after the receive side is closed) makes the stack send
 // an abortive RST instead of a graceful FIN, which can make the peer see the
 // an abortive RST instead of a graceful FIN, which can make the peer see the
 // response as a failed read even though it was fully written.
 // response as a failed read even though it was fully written.
-inline void close_socket_gracefully(socket_t sock) noexcept {
+inline void drain_and_close_socket(socket_t sock) noexcept {
 #ifdef _WIN32
 #ifdef _WIN32
   shutdown(sock, SD_SEND);
   shutdown(sock, SD_SEND);
 #else
 #else
@@ -13641,7 +13641,7 @@ inline bool Server::process_and_close_socket(socket_t sock) {
                                nullptr, &websocket_upgraded);
                                nullptr, &websocket_upgraded);
       });
       });
 
 
-  detail::close_socket_gracefully(sock);
+  detail::drain_and_close_socket(sock);
   return ret;
   return ret;
 }
 }