defer ESTABLISHED until after mode is WS_SERVING
authorAndy Green <andy@warmcat.com>
Wed, 6 Jul 2016 09:42:19 +0000 (17:42 +0800)
committerAndy Green <andy@warmcat.com>
Thu, 14 Jul 2016 00:57:28 +0000 (08:57 +0800)
lib/server-handshake.c
lib/server.c

index ef7c5ce..a0bddff 100644 (file)
@@ -260,19 +260,6 @@ handshake_0405(struct lws_context *context, struct lws *wsi)
        wsi->state = LWSS_ESTABLISHED;
        wsi->lws_rx_parse_state = LWS_RXPS_NEW;
 
-       /* notify user code that we're ready to roll */
-
-       if (wsi->protocol->callback)
-               if (wsi->protocol->callback(wsi, LWS_CALLBACK_ESTABLISHED,
-                                           wsi->user_space,
-#ifdef LWS_OPENSSL_SUPPORT
-                                           wsi->ssl,
-#else
-                                           NULL,
-#endif
-                                           0))
-                       goto bail;
-
        return 0;
 
 
index 3524d45..902bf94 100644 (file)
@@ -1279,6 +1279,19 @@ upgrade_ws:
                lwsl_parser("accepted v%02d connection\n",
                            wsi->ietf_spec_revision);
 
+               /* notify user code that we're ready to roll */
+
+               if (wsi->protocol->callback)
+                       if (wsi->protocol->callback(wsi, LWS_CALLBACK_ESTABLISHED,
+                                                   wsi->user_space,
+#ifdef LWS_OPENSSL_SUPPORT
+                                                   wsi->ssl,
+#else
+                                                   NULL,
+#endif
+                                                   0))
+                               return 1;
+
                return 0;
        } /* while all chars are handled */