adoption: close socket manually if fails before add fds

This commit is contained in:
Andy Green 2017-05-15 08:10:08 +08:00
parent fbc1ff6e7b
commit 3198446d3c
2 changed files with 7 additions and 1 deletions

View 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:

View 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;
}