Fix netutils configuration issues: CONFIG_NETUTILS_HTTPD_SENDFILE was missing from Kconfig; CONFIG_NET_HAVE_SOLINGER should be CONFIG_NET_SOLINGER; Type of CONFIG_NET_HTTPD_MAXPATH was wrong in Kconfig file. From Max

This commit is contained in:
Gregory Nutt 2014-07-11 12:30:23 -06:00
parent de31f2cce8
commit 767f1b2993
6 changed files with 41 additions and 30 deletions

View File

@ -99,7 +99,7 @@ static int telnetd_daemon(int argc, char *argv[])
{
FAR struct telnetd_s *daemon;
struct sockaddr_in myaddr;
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
struct linger ling;
#endif
socklen_t addrlen;
@ -187,7 +187,7 @@ static int telnetd_daemon(int argc, char *argv[])
/* Configure to "linger" until all data is sent when the socket is closed */
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
ling.l_onoff = 1;
ling.l_linger = 30; /* timeout is seconds */
if (setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)) < 0)

View File

@ -1039,7 +1039,7 @@ static int ftpd_dataopen(FAR struct ftpd_session_s *session)
return -errval;
}
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
{
struct linger ling;
@ -1070,7 +1070,7 @@ static int ftpd_dataopen(FAR struct ftpd_session_s *session)
close(session->data.sd);
session->data.sd = sd;
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
{
struct linger ling;
@ -3988,7 +3988,7 @@ static void ftpd_workersetup(FAR struct ftpd_session_s *session)
#if defined(CONFIG_NET_HAVE_IPTOS) || defined(CONFIG_NET_HAVE_OOBINLINE)
int temp;
#endif
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
struct linger ling;
#endif
@ -4002,7 +4002,7 @@ static void ftpd_workersetup(FAR struct ftpd_session_s *session)
(void)setsockopt(session->cmd.sd, SOL_SOCKET, SO_OOBINLINE, &temp, sizeof(temp));
#endif
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
(void)memset(&ling, 0, sizeof(ling));
ling.l_onoff = 1;
ling.l_linger = 4;

View File

@ -81,7 +81,7 @@
void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksize)
{
struct sockaddr_in myaddr;
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
struct linger ling;
#endif
pthread_t child;
@ -119,7 +119,7 @@ void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksiz
* closed.
*/
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
ling.l_onoff = 1;
ling.l_linger = 30; /* timeout is seconds */

View File

@ -99,7 +99,7 @@ static int telnetd_daemon(int argc, char *argv[])
{
FAR struct telnetd_s *daemon;
struct sockaddr_in myaddr;
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
struct linger ling;
#endif
socklen_t addrlen;
@ -187,7 +187,7 @@ static int telnetd_daemon(int argc, char *argv[])
/* Configure to "linger" until all data is sent when the socket is closed */
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
ling.l_onoff = 1;
ling.l_linger = 30; /* timeout is seconds */
if (setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)) < 0)

View File

@ -34,7 +34,7 @@ config NETUTILS_HTTPD_SCRIPT_DISABLE
This option, if selected, will elide the %! scripting
config NETUTILS_HTTPD_MAXPATH
bool "Maximum size of a path"
int "Maximum size of a path"
default 64
---help---
This is the maximum size of a PATH used in the web server. This setting
@ -112,7 +112,7 @@ config NETUTILS_HTTPD_MMAP
approach. NOTE, however, that since files are copied into memory,
this limits solution to small files that will fit into available RAM.
config NETUTILS_HTTPD_MMAP
config NETUTILS_HTTPD_SENDFILE
bool "sendfile()"
select NETUTILS_HTTPD_SCRIPT_DISABLE
---help---

View File

@ -73,11 +73,13 @@
* Pre-processor Definitions
****************************************************************************/
#if !defined(CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE) && defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
#if !defined(CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE) && \
defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
# error "Script support and CONFIG_NETUTILS_HTTPD_SENDFILE are mutually exclusive"
#endif
#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE) && defined(CONFIG_NETUTILS_HTTPD_MMAP)
#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE) && \
defined(CONFIG_NETUTILS_HTTPD_MMAP)
# error "CONFIG_NETUTILS_HTTPD_SENDFILE and CONFIG_NETUTILS_HTTPD_MMAP are mutually exclusive"
#endif
@ -115,7 +117,7 @@
# endif
#endif
#if !defined(CONFIG_NETUTILS_HTTPD_SENDFILE) && !defined(CONFIG_NETUTILS_HTTPD_MMAP)
#ifdef CONFIG_NETUTILS_HTTPD_CLASSIC
# ifndef CONFIG_NETUTILS_HTTPD_INDEX
# ifndef CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE
# define CONFIG_NETUTILS_HTTPD_INDEX "index.shtml"
@ -135,12 +137,14 @@
static int httpd_open(const char *name, struct httpd_fs_file *file)
{
#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
return httpd_sendfile_open(name, file);
#if defined(CONFIG_NETUTILS_HTTPD_CLASSIC)
return httpd_fs_open(name, file);
#elif defined(CONFIG_NETUTILS_HTTPD_MMAP)
return httpd_mmap_open(name, file);
#elif defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
return httpd_sendfile_open(name, file);
#else
return httpd_fs_open(name, file);
# error "No file handling method"
#endif
}
@ -156,7 +160,8 @@ static int httpd_openindex(struct httpd_state *pstate)
}
ret = httpd_open(pstate->ht_filename, &pstate->ht_file);
#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE) || defined(CONFIG_NETUTILS_HTTPD_MMAP)
#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE) || \
defined(CONFIG_NETUTILS_HTTPD_MMAP)
# if defined(CONFIG_NETUTILS_HTTPD_INDEX)
if (ret == ERROR && errno == EISDIR)
{
@ -173,12 +178,14 @@ static int httpd_openindex(struct httpd_state *pstate)
static int httpd_close(struct httpd_fs_file *file)
{
#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
return httpd_sendfile_close(file);
#if defined(CONFIG_NETUTILS_HTTPD_CLASSIC)
return OK;
#elif defined(CONFIG_NETUTILS_HTTPD_MMAP)
return httpd_mmap_close(file);
#elif defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
return httpd_sendfile_close(file);
#else
return OK;
# error "No file handling method"
#endif
}
@ -464,10 +471,12 @@ static int httpd_senderror(struct httpd_state *pstate, int status)
}
else
{
#ifdef CONFIG_NETUTILS_HTTPD_CLASSIC
ret = send_chunk(pstate, pstate->ht_file.data, pstate->ht_file.len);
#else
#ifdef CONFIG_NETUTILS_HTTPD_SENDFILE
ret = httpd_sendfile_send(pstate->ht_sockfd, &pstate->ht_file);
#else
ret = send_chunk(pstate, pstate->ht_file.data, pstate->ht_file.len);
#endif
#endif
(void)httpd_close(&pstate->ht_file);
@ -533,10 +542,12 @@ static int httpd_sendfile(struct httpd_state *pstate)
goto done;
}
#ifdef CONFIG_NETUTILS_HTTPD_CLASSIC
ret = send_chunk(pstate, pstate->ht_file.data, pstate->ht_file.len);
#else
#ifdef CONFIG_NETUTILS_HTTPD_SENDFILE
ret = httpd_sendfile_send(pstate->ht_sockfd, &pstate->ht_file);
#else
ret = send_chunk(pstate, pstate->ht_file.data, pstate->ht_file.len);
#endif
#endif
done:
@ -700,7 +711,7 @@ static inline int httpd_parse(struct httpd_state *pstate)
}
while (state != STATE_BODY);
#if !defined(CONFIG_NETUTILS_HTTPD_SENDFILE) && !defined(CONFIG_NETUTILS_HTTPD_MMAP)
#ifdef CONFIG_NETUTILS_HTTPD_CLASSIC
if (0 == strcmp(pstate->ht_filename, "/"))
{
strncpy(pstate->ht_filename, "/" CONFIG_NETUTILS_HTTPD_INDEX, strlen("/" CONFIG_NETUTILS_HTTPD_INDEX));
@ -782,7 +793,7 @@ static void single_server(uint16_t portno, pthread_startroutine_t handler, int s
socklen_t addrlen;
int listensd;
int acceptsd;
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
struct linger ling;
#endif
#if CONFIG_NETUTILS_HTTPD_TIMEOUT > 0
@ -812,7 +823,7 @@ static void single_server(uint16_t portno, pthread_startroutine_t handler, int s
/* Configure to "linger" until all data is sent when the socket is closed */
#ifdef CONFIG_NET_HAVE_SOLINGER
#ifdef CONFIG_NET_SOLINGER
ling.l_onoff = 1;
ling.l_linger = 30; /* timeout is seconds */
if (setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)) < 0)
@ -881,7 +892,7 @@ int httpd_listen(void)
void httpd_init(void)
{
#if !defined(CONFIG_NETUTILS_HTTPD_MMAP) && !defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
#ifdef CONFIG_NETUTILS_HTTPD_CLASSIC
httpd_fs_init();
#endif
}