Native version of lighttpd

The port of lighttpd at 'ports/src/app/lighttpd' executes the web server
directly (w/o using Noux). It is accompanied by the lighttpd.run script.

At the current stage, lighttpd is starting up but fails because of an
unsupport fcntl call.
This commit is contained in:
Norman Feske 2012-08-17 09:04:00 +02:00
parent 7a7adfbb63
commit 228e70bb5f
7 changed files with 249 additions and 2 deletions

View File

@ -1,2 +1,6 @@
LIGHTTPD_VERSION = 1.4.31
LIGHTTPD = lighttpd-$(LIGHTTPD_VERSION)
LIGHTTPD_MAIN := 1
LIGHTTPD_MAJOR := 4
LIGHTTPD_MINOR := 31
LIGHTTPD_VERSION := $(LIGHTTPD_MAIN).$(LIGHTTPD_MAJOR).$(LIGHTTPD_MINOR)
LIGHTTPD := lighttpd-$(LIGHTTPD_VERSION)

View File

@ -18,3 +18,4 @@ $(DOWNLOAD_DIR)/$(LIGHTTPD_TGZ):
$(CONTRIB_DIR)/$(LIGHTTPD): $(DOWNLOAD_DIR)/$(LIGHTTPD_TGZ)
$(VERBOSE)tar xfz $< -C $(CONTRIB_DIR) && touch $@
$(VERBOSE)patch -N -p1 < src/app/lighttpd/disable_gethostbyaddr_fcntl.patch

133
ports/run/lighttpd.run Normal file
View File

@ -0,0 +1,133 @@
#
# \brief Example for running lighttpd
# \author Norman Feske
# \date 2012-08-16
#
set build_components {
core init
drivers/pci
drivers/nic
drivers/timer
server/ram_fs
app/lighttpd
}
build $build_components
create_boot_directory
append config {
<config>
<parent-provides>
<service name="ROM"/>
<service name="LOG"/>
<service name="CAP"/>
<service name="RAM"/>
<service name="RM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="IRQ"/>
<service name="IO_PORT"/>
<service name="IO_MEM"/>
<service name="SIGNAL"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
</start>}
append_if [have_spec pci] config {
<start name="pci_drv">
<resource name="RAM" quantum="1M"/>
<provides><service name="PCI"/></provides>
</start>}
append config {
<start name="nic_drv">
<resource name="RAM" quantum="4M"/>
<provides><service name="Nic"/></provides>
</start>
<start name="ram_fs">
<resource name="RAM" quantum="10M"/>
<provides><service name="File_system"/></provides>
<config>
<policy label="lighttpd" root="/" />
<content>
<dir name="etc">
<dir name="lighttpd">
<inline name="lighttpd.conf">
# lighttpd configuration
server.port = 80
server.document-root = "/website"
server.event-handler = "select"
server.network-backend = "write"
index-file.names = (
"index.xhtml", "index.html", "index.htm"
)
mimetype.assign = (
".html" => "text/html",
".htm" => "text/html"
)
</inline>
</dir>
</dir>
<dir name="website">
<inline name="index.html">
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>Hello Genode!</p>
<b>I am bold ;-)</b>
</body>
</html>
</inline>
</dir>
</content>
</config>
</start>
<start name="lighttpd">
<resource name="RAM" quantum="1G" />
<config>
<arg value="lighttpd" />
<arg value="-f" />
<arg value="/etc/lighttpd/lighttpd.conf" />
<arg value="-D" />
</config>
</start>}
append config {
</config>}
install_config $config
#
# Boot modules
#
# generic modules
set boot_modules {
core init timer ld.lib.so nic_drv ram_fs
libc.lib.so libm.lib.so libc_fs.lib.so libc_log.lib.so
lwip.lib.so zlib.lib.so libcrypto.lib.so libssl.lib.so
lighttpd
}
# platform-specific modules
lappend_if [have_spec pci] boot_modules pci_drv
build_boot_image $boot_modules
append_if [have_spec x86] qemu_args " -net nic,model=e1000 "
append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 "
append qemu_args " -net user -redir tcp:5555::80 "
append qemu_args " -nographic -serial mon:stdio "
run_genode_until forever

View File

@ -0,0 +1,75 @@
--- a/contrib/lighttpd-1.4.31/src/fdevent_poll.c.orig
+++ b/contrib/lighttpd-1.4.31/src/fdevent_poll.c
@@ -193,7 +193,7 @@ int fdevent_poll_init(fdevents *ev) {
int fdevent_poll_init(fdevents *ev) {
UNUSED(ev);
- log_error_write(srv, __FILE__, __LINE__,
+ log_error_write(ev->srv, __FILE__, __LINE__,
"s", "poll is not supported, try to set server.event-handler = \"select\"");
return -1;
--- a/contrib/lighttpd-1.4.31/src/http-header-glue.c.orig
+++ b/contrib/lighttpd-1.4.31/src/http-header-glue.c
@@ -175,6 +175,7 @@ int http_response_redirect_to_directory(server *srv, connection *con) {
break;
#endif
case AF_INET:
+#if 0
if (NULL == (he = gethostbyaddr((char *)&our_addr.ipv4.sin_addr, sizeof(struct in_addr), AF_INET))) {
log_error_write(srv, __FILE__, __LINE__,
"SdS", "NOTICE: gethostbyaddr failed: ",
@@ -184,6 +185,8 @@ int http_response_redirect_to_directory(server *srv, connection *con) {
} else {
buffer_append_string(o, he->h_name);
}
+#endif
+ buffer_append_string(o, inet_ntoa(our_addr.ipv4.sin_addr));
break;
default:
log_error_write(srv, __FILE__, __LINE__,
--- a/contrib/lighttpd-1.4.31/src/network.c.orig
+++ b/contrib/lighttpd-1.4.31/src/network.c
@@ -301,6 +301,7 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
if (host == NULL) {
srv_socket->addr.ipv4.sin_addr.s_addr = htonl(INADDR_ANY);
} else {
+#if 0
struct hostent *he;
if (NULL == (he = gethostbyname(host))) {
log_error_write(srv, __FILE__, __LINE__,
@@ -320,6 +321,7 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
}
memcpy(&(srv_socket->addr.ipv4.sin_addr.s_addr), he->h_addr_list[0], he->h_length);
+#endif
}
srv_socket->addr.ipv4.sin_port = htons(port);
--- a/contrib/lighttpd-1.4.31/src/fdevent.c.orig
+++ b/contrib/lighttpd-1.4.31/src/fdevent.c
@@ -198,16 +198,23 @@ void * fdevent_get_context(fdevents *ev, int fd) {
}
int fdevent_fcntl_set(fdevents *ev, int fd) {
+#if 0
#ifdef FD_CLOEXEC
/* close fd on exec (cgi) */
fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
- if ((ev) && (ev->fcntl_set)) return ev->fcntl_set(ev, fd);
+ if ((ev) && (ev->fcntl_set)){
+ fprintf(stderr, "call ev->fcntl_set(ev, %d)\n", fd);
+ return ev->fcntl_set(ev, fd);
+ }
#ifdef O_NONBLOCK
+ fprintf(stderr, "call fcntl(ev, %d)\n", fd);
return fcntl(fd, F_SETFL, O_NONBLOCK | O_RDWR);
#else
return 0;
#endif
+#endif
+ return 0;
}

View File

@ -0,0 +1,4 @@
PLUGIN_INIT(mod_indexfile)
PLUGIN_INIT(mod_dirlisting)
PLUGIN_INIT(mod_staticfile)
PLUGIN_INIT(mod_access)

View File

@ -0,0 +1,25 @@
include $(REP_DIR)/ports/lighttpd.inc
LIGHTTPD_DIR = $(REP_DIR)/contrib/$(LIGHTTPD)
FILTER_OUT = lempar.c lighttpd-angel.c lemon.c
SRC_C = $(filter-out $(FILTER_OUT),$(notdir $(wildcard $(LIGHTTPD_DIR)/src/*.c)))
vpath %.c $(LIGHTTPD_DIR)/src
CC_OPT += -DHAVE_SOCKLEN_T -DHAVE_SYSLOG_H -DHAVE_STDINT_H -DUSE_POLL
CC_OPT += -DHAVE_SYS_WAIT_H -DHAVE_SYS_UN_H -DHAVE_MMAP -DHAVE_SELECT
CC_OPT += -DHAVE_WRITEV -DUSE_WRITEV
CC_OPT += -DSBIN_DIR="\"/sbin\""
CC_OPT += -DPACKAGE_NAME="\"lighttpd\""
CC_OPT += -DLIGHTTPD_VERSION_ID='($(LIGHTTPD_MAIN) << 16 | $(LIGHTTPD_MAJOR) << 8 | $(LIGHTTPD_MINOR))'
CC_OPT += -DPACKAGE_VERSION="\"$(LIGHTTPD_MAIN).$(LIGHTTPD_MAJOR).$(LIGHTTPD_MINOR)\""
CC_OPT += -DLIBRARY_DIR="\"/lib\""
CC_OPT += -DLIGHTTPD_STATIC
CC_WARN = -Wall -Wno-unused-variable -Wno-unused-function
INC_DIR += $(PRG_DIR)
INC_DIR += $(LIGHTTPD_DIR)/src
LIBS += cxx env libc libm
LIBS += libcrypto libssl zlib config_args

View File

@ -0,0 +1,5 @@
TARGET = lighttpd
include $(REP_DIR)/src/app/lighttpd/target.inc
LIBS += cxx env libc libm libc_log libc_fs libc_lwip_nic_dhcp