You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/11/27 03:28:30 UTC
[incubator-nuttx-apps] 06/07: netutils/thttpd/thttpd.c: Appease
nxstyle
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit c04f59cb2e6aff88e57e327128fb7df36723a09d
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Nov 26 19:58:33 2020 +0900
netutils/thttpd/thttpd.c: Appease nxstyle
The following nxstyle errors are intentionally left.
The first one is in the copyright notice.
The others are identifiers like ClientData etc.
netutils/thttpd/thttpd.c:10:81: error: Long line found
netutils/thttpd/thttpd.c:99:2: error: Mixed case identifier found
netutils/thttpd/thttpd.c:100:2: error: Mixed case identifier found
netutils/thttpd/thttpd.c:131:17: error: Mixed case identifier found
netutils/thttpd/thttpd.c:131:57: error: Mixed case identifier found
netutils/thttpd/thttpd.c:132:36: error: Mixed case identifier found
netutils/thttpd/thttpd.c:133:52: error: Mixed case identifier found
netutils/thttpd/thttpd.c:134:23: error: Mixed case identifier found
netutils/thttpd/thttpd.c:134:63: error: Mixed case identifier found
netutils/thttpd/thttpd.c:527:2: error: Mixed case identifier found
netutils/thttpd/thttpd.c:597:17: error: Mixed case identifier found
netutils/thttpd/thttpd.c:597:57: error: Mixed case identifier found
netutils/thttpd/thttpd.c:608:14: error: Mixed case identifier found
netutils/thttpd/thttpd.c:615:38: error: Mixed case identifier found
netutils/thttpd/thttpd.c:620:14: error: Mixed case identifier found
netutils/thttpd/thttpd.c:625:37: error: Mixed case identifier found
netutils/thttpd/thttpd.c:632:36: error: Mixed case identifier found
netutils/thttpd/thttpd.c:633:52: error: Mixed case identifier found
netutils/thttpd/thttpd.c:643:23: error: Mixed case identifier found
netutils/thttpd/thttpd.c:643:63: error: Mixed case identifier found
netutils/thttpd/thttpd.c:730:35: error: Mixed case identifier found
netutils/thttpd/thttpd.c:739:29: error: Mixed case identifier found
---
netutils/thttpd/thttpd.c | 58 ++++++++++++++++++++++++++++++------------------
1 file changed, 37 insertions(+), 21 deletions(-)
diff --git a/netutils/thttpd/thttpd.c b/netutils/thttpd/thttpd.c
index 83d8a45..ceaf450 100644
--- a/netutils/thttpd/thttpd.c
+++ b/netutils/thttpd/thttpd.c
@@ -129,7 +129,8 @@ static void finish_connection(struct connect_s *conn, struct timeval *tv);
static void clear_connection(struct connect_s *conn, struct timeval *tv);
static void really_clear_connection(struct connect_s *conn);
static void idle(ClientData client_data, struct timeval *nowP);
-static void linger_clear_connection(ClientData client_data, struct timeval *nowP);
+static void linger_clear_connection(ClientData client_data,
+ struct timeval *nowP);
static void occasional(ClientData client_data, struct timeval *nowP);
/****************************************************************************
@@ -163,6 +164,7 @@ static void shut_down(void)
{
fdwatch_del_fd(fw, ths->listen_fd);
}
+
httpd_terminate(ths);
}
@@ -179,7 +181,7 @@ static int handle_newconnect(FAR struct timeval *tv, int listen_fd)
*/
ninfo("New connection(s) on listen_fd %d\n", listen_fd);
- for (;;)
+ for (; ; )
{
/* Get the next free connection from the free list */
@@ -269,12 +271,15 @@ static void handle_read(struct connect_s *conn, struct timeval *tv)
BADREQUEST("MAXREALLOC");
goto errout_with_400;
}
- httpd_realloc_str(&hc->read_buf, &hc->read_size, hc->read_size + CONFIG_THTTPD_REALLOCINCR);
+
+ httpd_realloc_str(&hc->read_buf, &hc->read_size,
+ hc->read_size + CONFIG_THTTPD_REALLOCINCR);
}
/* Read some more bytes */
- sz = read(hc->conn_fd, &(hc->read_buf[hc->read_idx]), hc->read_size - hc->read_idx);
+ sz = read(hc->conn_fd, &(hc->read_buf[hc->read_idx]),
+ hc->read_size - hc->read_idx);
if (sz == 0)
{
BADREQUEST("EOF");
@@ -414,6 +419,7 @@ static inline int read_buffer(struct connect_s *conn)
hc->buflen += nread;
}
}
+
return nread;
}
@@ -438,6 +444,7 @@ static void handle_send(struct connect_s *conn, struct timeval *tv)
nerr("ERROR: File read error: %d\n", errno);
goto errout_clear_connection;
}
+
ninfo("Read %d bytes, buflen %d\n", nread, hc->buflen);
/* Send the buffer */
@@ -488,7 +495,7 @@ static void handle_linger(struct connect_s *conn, struct timeval *tv)
httpd_conn *hc = conn->hc;
int ret;
- /* In lingering-close mode we just read and ignore bytes. An error or EOF
+ /* In lingering-close mode we just read and ignore bytes. An error or EOF
* ends things, otherwise we go until a timeout
*/
@@ -552,7 +559,8 @@ static void clear_connection(struct connect_s *conn, struct timeval *tv)
fdwatch_add_fd(fw, conn->hc->conn_fd, conn);
client_data.p = conn;
- conn->linger_timer = tmr_create(tv, linger_clear_connection, client_data,
+ conn->linger_timer = tmr_create(tv, linger_clear_connection,
+ client_data,
CONFIG_THTTPD_LINGER_MSEC, 0);
if (conn->linger_timer != NULL)
{
@@ -562,7 +570,9 @@ static void clear_connection(struct connect_s *conn, struct timeval *tv)
nerr("ERROR: tmr_create(linger_clear_connection) failed\n");
}
- /* Either we are done lingering, we shouldn't linger, or we failed to setup the linger */
+ /* Either we are done lingering, we shouldn't linger, or we failed to
+ * setup the linger
+ */
really_clear_connection(conn);
}
@@ -595,7 +605,8 @@ static void idle(ClientData client_data, struct timeval *nowP)
switch (conn->conn_state)
{
case CNST_READING:
- if (nowP->tv_sec - conn->active_at >= CONFIG_THTTPD_IDLE_READ_LIMIT_SEC)
+ if (nowP->tv_sec - conn->active_at >=
+ CONFIG_THTTPD_IDLE_READ_LIMIT_SEC)
{
nerr("ERROR: %s connection timed out reading\n",
httpd_ntoa(&conn->hc->client_addr));
@@ -606,7 +617,8 @@ static void idle(ClientData client_data, struct timeval *nowP)
break;
case CNST_SENDING:
- if (nowP->tv_sec - conn->active_at >= CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC)
+ if (nowP->tv_sec - conn->active_at >=
+ CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC)
{
nerr("ERROR: %s connection timed out sending\n",
httpd_ntoa(&conn->hc->client_addr));
@@ -617,7 +629,8 @@ static void idle(ClientData client_data, struct timeval *nowP)
}
}
-static void linger_clear_connection(ClientData client_data, struct timeval *nowP)
+static void linger_clear_connection(ClientData client_data,
+ struct timeval *nowP)
{
struct connect_s *conn;
@@ -714,7 +727,8 @@ int thttpd_main(int argc, char **argv)
/* Set up the occasional timer */
- if (tmr_create(NULL, occasional, JunkClientData, CONFIG_THTTPD_OCCASIONAL_MSEC * 1000L, 1) == NULL)
+ if (tmr_create(NULL, occasional, JunkClientData,
+ CONFIG_THTTPD_OCCASIONAL_MSEC * 1000L, 1) == NULL)
{
nerr("ERROR: tmr_create(occasional) failed\n");
exit(1);
@@ -726,7 +740,6 @@ int thttpd_main(int argc, char **argv)
{
nerr("ERROR: tmr_create(idle) failed\n");
exit(1);
-
}
/* Initialize our connections table */
@@ -745,8 +758,8 @@ int thttpd_main(int argc, char **argv)
connects[cnum].hc = NULL;
}
- connects[AVAILABLE_FDS-1].next = NULL; /* End of link list */
- free_connections = connects; /* Beginning of the link list */
+ connects[AVAILABLE_FDS - 1].next = NULL; /* End of link list */
+ free_connections = connects; /* Beginning of the link list */
if (hs != NULL)
{
@@ -760,7 +773,7 @@ int thttpd_main(int argc, char **argv)
ninfo("Entering the main loop\n");
gettimeofday(&tv, NULL);
- for (;;)
+ for (; ; )
{
/* Do the fd watch */
@@ -805,7 +818,8 @@ int thttpd_main(int argc, char **argv)
/* Find the connections that need servicing */
- while ((conn = (struct connect_s*)fdwatch_get_next_client_data(fw)) != (struct connect_s*)-1)
+ while ((conn = (struct connect_s *)fdwatch_get_next_client_data(fw))
+ != (struct connect_s *)-1)
{
if (conn)
{
@@ -819,8 +833,9 @@ int thttpd_main(int argc, char **argv)
{
handle_read(conn, &tv);
- /* If a GET request was received and a file is ready to
- * be sent, then fall through to send the file.
+ /* If a GET request was received and a file is
+ * ready to be sent, then fall through to send
+ * the file.
*/
if (conn->conn_state != CNST_SENDING)
@@ -831,9 +846,9 @@ int thttpd_main(int argc, char **argv)
case CNST_SENDING:
{
- /* Send a file -- this really should be performed on a
- * separate thread to keep the serve from locking up during
- * the write.
+ /* Send a file -- this really should be performed
+ * on a separate thread to keep the serve from
+ * locking up during the write.
*/
handle_send(conn, &tv);
@@ -851,6 +866,7 @@ int thttpd_main(int argc, char **argv)
}
}
}
+
tmr_run(&tv);
}