The examples/webserver app can be built in two modes:
(1) in standalone mode, or
(2) as a NSH built-in app.
When run in standalone mode, the webserver program is responsible for
bringing up the network (including DHCP if configured). Also, the
webserver program must never exit, so if httpd fails (i.e., if
httpd_listen() returns), webserver_main() goes into an endless loop.
When run as a NSH built-in app, network bring-up is the responsibility
of other processes and the webserver program assumes the network is
already properly configured when it starts. Also, if httpd_listen()
returns, the webserver program should terminate.
Prior to this change, the webserver program would *not* terminate,
even when running as a NSH built-in app. For example:
nsh> webserver &
webserver [6:100]
nsh> Starting webserver
nsh> kill -9 6
nsh> webserver_main: Still running
nsh> webserver_main: Still running
nsh> webserver_main: Still running
nsh> webserver_main: Still running
The line "webserver_main: Still running" would be forever printed
every 3 seconds, however httpd_listen() is no longer running and the
webserver is not functional.
This change makes the webserver play nicely when running as a NSH
built-in app. With this change applied:
nsh> webserver &
webserver [6:100]
nsh> Starting webserver
nsh> kill -9 6
nsh> webserver_main: Exiting
apps/examples/webserver/webserver_main.c:
* main(): Infer from CONFIG_NSH_BUILTIN_APPS if this is a
standalone program or a NSH built-in app. (See [1], where
similar logic was added to decide whether to do network bring-up
or not.) If standalone, run forever as before. If built-in
app, exit when httpd terminates.
References:
[1] Commit 3a21b0b222
For now, I left the following instances because it isn't
clear to me why they are using the different values.
Maybe they need one-by-one inspection.
examples/igmp/Makefile:STACKSIZE = 1024
examples/powerled/Makefile:STACKSIZE = 1024
examples/powermonitor/Makefile:STACKSIZE = 768
examples/relays/Makefile:STACKSIZE = 512
examples/smps/Makefile:STACKSIZE = 1024
graphics/screenshot/Makefile:STACKSIZE = 4096
system/flash_eraseall/Makefile:STACKSIZE = 1024
testing/cxxtest/Makefile:STACKSIZE = 4096
testing/smart_test/Makefile:STACKSIZE = 4096
1.Remove void cast for function because many place ignore the returned value witout cast
2.Replace void cast for variable with UNUSED macro
Change-Id: Ie644129a563244a6397036789c4c3ea83c4e9b09
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
1. Check NSH_NETINIT for self network initialization
2. Check NSH_ARCHINIT for sel arch specific initialization
3. Always show help regardless of NSH_BUILTIN_APPS
4. Loop forever regardless of NSH_BUILTIN_APPS, user could:
a.change the default behavior by the command line argument
b.or ctrl+c to break out the loop
apps/examples/webserver: Fix to compile with CONFIG_NETUTILS_HTTPD_SENDFILE=y
Also, in this PR, some configs such as CONFIG_NETUTILS_HTTPDFILESTATS
can be selected by menuconfig.
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Approved-by: Gregory Nutt <gnutt@nuttx.org>
The patch provided in issue 135, which adds support for HTTP Chunked Encoding, covers all paths in the webserver app except CGI callbacks. As a result, if a page being served happens to use CGI, it could generate stream content that does not comply with HTTP Chunked Encoding.
The patch attached amends the webserver app's CGI callbacks to use the HTTP Chunked Encoding sender function instead of using send() directly.
Author: anchao <anchao@pinecone.net>
apps/, most main() function: Correct CONFIG_BUILD_LOADABLE usage
Loadable apps/: Correct loadable symbol table generate
apps/system/ubloxmodem: Fix build break
apps/examples/ostest: start restart/waitpid/user test from main loop
apps/nshlib: Expand reboot and poweroff commands to include a second, optional mode argument
Author: Gregory Nutt <gnutt@nuttx.org>
An attempt to fix build issues. Does not work.
apps/examples/ostest: Fix some inappropriate renaming of static functions introduced with recent patches.
apps/builtin/exec_builtin.c: Fix a error introduced by recent comments. Found in build testing.
Author: anchao <anchao@pinecone.net>
apps/builtin/exec_builtin.c: Try posix_spawn if builtin apps do not have have an entry point.
apps/Application.mk: introduce MODULE config to simplify tristate(m)
apps/nsh: Change the nuttx shell module type to tristate
apps: Add loadable application support
script/mksymtab: Generate symbol table name by default
apps/builtin: Allow loadable applications can register with apps/builtin.
apps/builtin/exec_builtin.c: Try posix_spawn if builtin apps do not have have an entry point.
apps/Application.mk: introduce MODULE config to simplify tristate(m)
apps/nsh: Change the nuttx shell module type to tristate
apps: Add loadable application support
script/mksymtab: Generate symbol table name by default
apps/builtin: Allow loadable applications can register with apps/builtin.