Просмотр исходного кода

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 3 дней назад
Родитель
Сommit
f978bb5ca1
1 измененных файлов с 2 добавлено и 2 удалено
  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
 // 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.
-inline void close_socket_gracefully(socket_t sock) noexcept {
+inline void drain_and_close_socket(socket_t sock) noexcept {
 #ifdef _WIN32
   shutdown(sock, SD_SEND);
 #else
@@ -13641,7 +13641,7 @@ inline bool Server::process_and_close_socket(socket_t sock) {
                                nullptr, &websocket_upgraded);
       });
 
-  detail::close_socket_gracefully(sock);
+  detail::drain_and_close_socket(sock);
   return ret;
 }