Skip to content

Commit

Permalink
limit sockets used by HTTP server (#122)
Browse files Browse the repository at this point in the history
seems that ctrl and msg sockets are not needed
  • Loading branch information
philippe44 committed Nov 17, 2021
1 parent faa9976 commit c236044
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions components/wifi-manager/_esp_httpd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,7 @@ static esp_err_t _httpd_server_init(struct httpd_data *hd)
return ESP_FAIL;
}

int ctrl_fd = cs_create_ctrl_sock(hd->config.ctrl_port);
if (ctrl_fd < 0) {
ESP_LOGE(TAG, LOG_FMT("error in creating ctrl socket (%d)"), errno);
close(fd);
return ESP_FAIL;
}

int msg_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (msg_fd < 0) {
ESP_LOGE(TAG, LOG_FMT("error in creating msg socket (%d)"), errno);
close(fd);
close(ctrl_fd);
return ESP_FAIL;
}

hd->listen_fd = fd;
hd->ctrl_fd = ctrl_fd;
hd->msg_fd = msg_fd;
return ESP_OK;
}

Expand Down Expand Up @@ -198,14 +181,6 @@ static esp_err_t _httpd_server(struct httpd_data *hd)
}

/* Case0: Do we have a control message? */
if (FD_ISSET(hd->ctrl_fd, &read_set)) {
ESP_LOGD(TAG, LOG_FMT("processing ctrl message"));
_httpd_process_ctrl_msg(hd);
if (hd->hd_td.status == THREAD_STOPPING) {
ESP_LOGD(TAG, LOG_FMT("stopping thread"));
return ESP_FAIL;
}
}

/* Case1: Do we have any activity on the current data
* sessions? */
Expand Down Expand Up @@ -259,8 +234,6 @@ static void _httpd_thread(void *arg)
}

ESP_LOGD(TAG, LOG_FMT("web server exiting"));
close(hd->msg_fd);
cs_free_ctrl_sock(hd->ctrl_fd);
_httpd_close_all_sessions(hd);
close(hd->listen_fd);
hd->hd_td.status = THREAD_STOPPED;
Expand Down

0 comments on commit c236044

Please sign in to comment.