esp_http_server: Run format.sh script to fix code style issues

This commit is contained in:
Shubham Kulkarni
2021-02-17 10:43:19 +05:30
committed by bot
parent 282726b619
commit 6a7587d35f
3 changed files with 87 additions and 89 deletions

View File

@@ -197,7 +197,7 @@ esp_err_t httpd_sess_new(struct httpd_data *hd, int newfd);
* @brief Processes incoming HTTP requests * @brief Processes incoming HTTP requests
* *
* @param[in] hd Server instance data * @param[in] hd Server instance data
* @param[in] session session * @param[in] session Session
* *
* @return * @return
* - ESP_OK : on successfully receiving, parsing and responding to a request * - ESP_OK : on successfully receiving, parsing and responding to a request

View File

@@ -60,12 +60,12 @@ static esp_err_t httpd_accept_conn(struct httpd_data *hd, int listen_fd)
/* Set recv timeout of this fd as per config */ /* Set recv timeout of this fd as per config */
tv.tv_sec = hd->config.recv_wait_timeout; tv.tv_sec = hd->config.recv_wait_timeout;
tv.tv_usec = 0; tv.tv_usec = 0;
setsockopt(new_fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof(tv)); setsockopt(new_fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv));
/* Set send timeout of this fd as per config */ /* Set send timeout of this fd as per config */
tv.tv_sec = hd->config.send_wait_timeout; tv.tv_sec = hd->config.send_wait_timeout;
tv.tv_usec = 0; tv.tv_usec = 0;
setsockopt(new_fd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv, sizeof(tv)); setsockopt(new_fd, SOL_SOCKET, SO_SNDTIMEO, (const char *)&tv, sizeof(tv));
if (ESP_OK != httpd_sess_new(hd, new_fd)) { if (ESP_OK != httpd_sess_new(hd, new_fd)) {
ESP_LOGW(TAG, LOG_FMT("session creation failed")); ESP_LOGW(TAG, LOG_FMT("session creation failed"));
@@ -178,10 +178,10 @@ static int httpd_process_session(struct sock_db *session, void *context)
return 1; return 1;
} }
process_session_context_t * ctx=(process_session_context_t*)context; process_session_context_t *ctx = (process_session_context_t *)context;
int fd=session->fd; int fd = session->fd;
if (FD_ISSET(fd, ctx->fdset) || httpd_sess_pending(ctx->hd,session)) { if (FD_ISSET(fd, ctx->fdset) || httpd_sess_pending(ctx->hd, session)) {
ESP_LOGD(TAG, LOG_FMT("processing socket %d"), fd); ESP_LOGD(TAG, LOG_FMT("processing socket %d"), fd);
if (httpd_sess_process(ctx->hd, session) != ESP_OK) { if (httpd_sess_process(ctx->hd, session) != ESP_OK) {
httpd_sess_delete(ctx->hd, session); // Delete session httpd_sess_delete(ctx->hd, session); // Delete session

View File

@@ -122,7 +122,7 @@ static int enum_function(struct sock_db *session, void *context)
} }
break; break;
case HTTPD_TASK_CLOSE: case HTTPD_TASK_CLOSE:
if (session->fd!=-1) { if (session->fd != -1) {
ESP_LOGD(TAG, LOG_FMT("cleaning up socket %d"), session->fd); ESP_LOGD(TAG, LOG_FMT("cleaning up socket %d"), session->fd);
httpd_sess_delete(ctx->hd, session); httpd_sess_delete(ctx->hd, session);
} }
@@ -236,8 +236,7 @@ void httpd_sess_free_ctx(void **ctx, httpd_free_ctx_fn_t free_fn)
} }
if (free_fn) { if (free_fn) {
free_fn(*ctx); free_fn(*ctx);
} } else {
else {
free(*ctx); free(*ctx);
} }
*ctx = NULL; *ctx = NULL;
@@ -272,7 +271,7 @@ void *httpd_sess_get_ctx(httpd_handle_t handle, int sockfd)
// Check if the function has been called from inside a // Check if the function has been called from inside a
// request handler, in which case fetch the context from // request handler, in which case fetch the context from
// the httpd_req_t structure // the httpd_req_t structure
struct httpd_data * hd = (struct httpd_data *) handle; struct httpd_data *hd = (struct httpd_data *) handle;
if (hd->hd_req_aux.sd == session) { if (hd->hd_req_aux.sd == session) {
return hd->hd_req.sess_ctx; return hd->hd_req.sess_ctx;
} }
@@ -357,7 +356,7 @@ void httpd_sess_delete_invalid(struct httpd_data *hd)
void httpd_sess_delete(struct httpd_data *hd, struct sock_db *session) void httpd_sess_delete(struct httpd_data *hd, struct sock_db *session)
{ {
if ((!hd) || (!session) || (session->fd<0)) { if ((!hd) || (!session) || (session->fd < 0)) {
return; return;
} }
@@ -366,8 +365,7 @@ void httpd_sess_delete(struct httpd_data *hd, struct sock_db *session)
// Call close function if defined // Call close function if defined
if (hd->config.close_fn) { if (hd->config.close_fn) {
hd->config.close_fn(hd, session->fd); hd->config.close_fn(hd, session->fd);
} } else {
else {
close(session->fd); close(session->fd);
} }
@@ -481,7 +479,7 @@ esp_err_t httpd_sess_trigger_close(httpd_handle_t handle, int sockfd)
if (!session) { if (!session) {
return ESP_ERR_NOT_FOUND; return ESP_ERR_NOT_FOUND;
} }
return httpd_sess_trigger_close_(handle,session); return httpd_sess_trigger_close_(handle, session);
} }
void httpd_sess_close_all(struct httpd_data *hd) void httpd_sess_close_all(struct httpd_data *hd)