adoption: close socket manually if fails before add fds
authorAndy Green <andy@warmcat.com>
Mon, 15 May 2017 00:10:08 +0000 (08:10 +0800)
committerAndy Green <andy@warmcat.com>
Mon, 15 May 2017 00:10:08 +0000 (08:10 +0800)
lib/lws-plat-esp32.c
lib/server.c

index 1d73f2f..40e51f9 100644 (file)
@@ -914,7 +914,9 @@ esp_err_t lws_esp32_event_passthru(void *ctx, system_event_t *event)
        char slot[8];
        nvs_handle nvh;
        uint32_t use;
+#if !defined(CONFIG_LWS_IS_FACTORY_APPLICATION)
        int n;
+#endif
 
        switch(event->event_id) {
        case SYSTEM_EVENT_STA_START:
index 762d628..acadcd6 100644 (file)
@@ -1784,8 +1784,10 @@ lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type,
                                 vh_prot_name, new_wsi->vhost->name);
                        goto bail;
                }
-               if (lws_ensure_user_space(new_wsi))
+               if (lws_ensure_user_space(new_wsi)) {
+                       lwsl_notice("OOM trying to get user_space\n");
                        goto bail;
+               }
        } else
                if (type & LWS_ADOPT_HTTP) /* he will transition later */
                        new_wsi->protocol =
@@ -1889,11 +1891,13 @@ fail:
        return NULL;
 
 bail:
+       lwsl_notice("%s: exiting on bail\n", __func__);
        if (parent)
                parent->child_list = new_wsi->sibling_list;
        if (new_wsi->user_space)
                lws_free(new_wsi->user_space);
        lws_free(new_wsi);
+       compatible_close(fd.sockfd);
 
        return NULL;
 }