Преглед изворни кода

Replace usage of MHD_Connection::tls_closed with MHD_Connection::tls_state

Evgeny Grin (Karlson2k) пре 8 година
родитељ
комит
730134054b
2 измењених фајлова са 17 додато и 9 уклоњено
  1. 17 4
      src/microhttpd/connection_https.c
  2. 0 5
      src/microhttpd/internal.h

+ 17 - 4
src/microhttpd/connection_https.c

@@ -246,12 +246,25 @@ MHD_set_https_callbacks (struct MHD_Connection *connection)
 bool
 MHD_tls_connection_shutdown (struct MHD_Connection *connection)
 {
-  if (! connection->tls_closed)
+  if (MHD_TLS_CONN_WR_CLOSED > connection->tls_state)
     {
-      connection->tls_closed =
-          (GNUTLS_E_SUCCESS == gnutls_bye(connection->tls_session, GNUTLS_SHUT_WR));
+      const int res =
+          gnutls_bye(connection->tls_session, GNUTLS_SHUT_WR);
+      if (GNUTLS_E_SUCCESS == ret)
+        {
+          connection->tls_state = MHD_TLS_CONN_WR_CLOSED;
+          return true;
+        }
+      if ((GNUTLS_E_AGAIN == ret) ||
+          (GNUTLS_E_INTERRUPTED == ret))
+        {
+          connection->tls_state = MHD_TLS_CONN_WR_CLOSING;
+          return true;
+        }
+      else
+        connection->tls_state = MHD_TLS_CONN_TLS_FAILED;
     }
-  return connection->tls_closed ? MHD_YES : MHD_NO;;
+  return false;
 }
 
 /* end of connection_https.c */

+ 0 - 5
src/microhttpd/internal.h

@@ -989,11 +989,6 @@ struct MHD_Connection
    * even though the socket is not?
    */
   bool tls_read_ready;
-
-  /**
-   * TLS layer was shut down?
-   */
-  bool tls_closed;
 #endif /* HTTPS_SUPPORT */
 
   /**