Hello,

While trying mongoose 5.5 and SSL under Linux, I believe I came across the 
following issue, which manifested itself (if I remember correctly) as 
unresponsive web browser connections and reception of partial data (both 
chrome & firefox).

When a SSL_read/SSL_write method triggers an 
SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE error, the 
NSF_WANT_READ/NSF_WANT_WRITE flags are set appropriately. However, when the 
error is subsequently resolved by another SSL_* operation, the NSF_WANT_* 
flags are not reset to their neutral state. As a result, the aborted 
operation does not resume.

I am attaching the change that resolved the issue for me, in order to 
further clarify. Is this a genuine issue or am I misusing mongoose somehow?

Thank you,
Nikos

-- 
You received this message because you are subscribed to the Google Groups 
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mongoose-users+unsubscr...@googlegroups.com.
To post to this group, send email to mongoose-users@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/d/optout.
@@ -889,6 +889,8 @@ static void ns_read_from_socket(struct ns_connection *conn) 
{
       } else {
         ok = 1;
       }
+      conn->flags &= ~NSF_WANT_READ;
+      conn->flags &= ~NSF_WANT_WRITE;
     }
 #endif
     conn->flags &= ~NSF_CONNECTING;
@@ -917,6 +919,8 @@ static void ns_read_from_socket(struct ns_connection *conn) 
{
       int ssl_err = ns_ssl_err(conn, res);
       if (res == 1) {
         conn->flags |= NSF_SSL_HANDSHAKE_DONE;
+        conn->flags &= ~NSF_WANT_READ;
+        conn->flags &= ~NSF_WANT_WRITE;
       } else if (ssl_err == SSL_ERROR_WANT_READ ||
                  ssl_err == SSL_ERROR_WANT_WRITE) {
         return; // Call us again
@@ -955,6 +959,10 @@ static void ns_write_to_socket(struct ns_connection *conn) 
{
         conn->flags |= NSF_CLOSE_IMMEDIATELY;
       }
     }
+    else {
+      conn->flags &= ~NSF_WANT_READ;
+      conn->flags &= ~NSF_WANT_WRITE;
+    }
   } else
 #endif
   { n = (int) send(conn->sock, io->buf, io->len, 0); }

Reply via email to