Skip to content

Commit

Permalink
fully remove ctrl_fd (was uninitialized in server loop) - release
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe44 committed Nov 18, 2021
1 parent 5d09d4f commit 635d382
Showing 1 changed file with 3 additions and 37 deletions.
40 changes: 3 additions & 37 deletions components/wifi-manager/_esp_httpd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,35 +80,6 @@ static esp_err_t _httpd_server_init(struct httpd_data *hd)
return ESP_OK;
}

static void _httpd_process_ctrl_msg(struct httpd_data *hd)
{
struct httpd_ctrl_data msg;
int ret = recv(hd->ctrl_fd, &msg, sizeof(msg), 0);
if (ret <= 0) {
ESP_LOGW(TAG, LOG_FMT("error in recv (%d)"), errno);
return;
}
if (ret != sizeof(msg)) {
ESP_LOGW(TAG, LOG_FMT("incomplete msg"));
return;
}

switch (msg.hc_msg) {
case HTTPD_CTRL_WORK:
if (msg.hc_work) {
ESP_LOGD(TAG, LOG_FMT("work"));
(*msg.hc_work)(msg.hc_work_arg);
}
break;
case HTTPD_CTRL_SHUTDOWN:
ESP_LOGD(TAG, LOG_FMT("shutdown"));
hd->hd_td.status = THREAD_STOPPING;
break;
default:
break;
}
}

static esp_err_t _httpd_accept_conn(struct httpd_data *hd, int listen_fd)
{
/* If no space is available for new session, close the least recently used one */
Expand Down Expand Up @@ -164,13 +135,10 @@ static esp_err_t _httpd_server(struct httpd_data *hd)
* older connections will be closed) */
FD_SET(hd->listen_fd, &read_set);
}
FD_SET(hd->ctrl_fd, &read_set);

int tmp_max_fd;
httpd_sess_set_descriptors(hd, &read_set, &tmp_max_fd);
int maxfd = MAX(hd->listen_fd, tmp_max_fd);
tmp_max_fd = maxfd;
maxfd = MAX(hd->ctrl_fd, tmp_max_fd);
int maxfd;
httpd_sess_set_descriptors(hd, &read_set, &maxfd);
maxfd = MAX(hd->listen_fd, maxfd);

ESP_LOGD(TAG, LOG_FMT("doing select maxfd+1 = %d"), maxfd + 1);
int active_cnt = select(maxfd + 1, &read_set, NULL, NULL, NULL);
Expand All @@ -180,8 +148,6 @@ static esp_err_t _httpd_server(struct httpd_data *hd)
return ESP_OK;
}

/* Case0: Do we have a control message? */

/* Case1: Do we have any activity on the current data
* sessions? */
int fd = -1;
Expand Down

0 comments on commit 635d382

Please sign in to comment.