aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--INSTALL103
-rw-r--r--README34
-rw-r--r--configure.ac32
-rw-r--r--src/daemon/Makefile.am8
-rw-r--r--src/daemon/connection.c44
-rw-r--r--src/daemon/daemon.c41
-rw-r--r--src/daemon/internal.c3
-rw-r--r--src/daemon/internal.h2
-rw-r--r--src/daemon/memorypool.c2
10 files changed, 208 insertions, 68 deletions
diff --git a/ChangeLog b/ChangeLog
index d95139e2..8be3cfd6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
1Sun Sep 9 14:32:23 MDT 2007
2 Added option to compile debug/warning messages;
3 error messages are now disabled by default.
4 Modified linker option for GNU LD to not export
5 non-public symbols (further reduces binary size).
6 Releasing libmicrohttpd 0.1.0. - CG
7
1Sat Sep 8 21:54:04 MDT 2007 8Sat Sep 8 21:54:04 MDT 2007
2 Extended API to allow for incremental POST 9 Extended API to allow for incremental POST
3 processing. The new API is binary-compatible 10 processing. The new API is binary-compatible
diff --git a/INSTALL b/INSTALL
index 5458714e..54caf7c1 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,19 +1,13 @@
1Installation Instructions 1Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
2************************* 2Foundation, Inc.
3 3
4Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 4 This file is free documentation; the Free Software Foundation gives
52006 Free Software Foundation, Inc.
6
7This file is free documentation; the Free Software Foundation gives
8unlimited permission to copy, distribute and modify it. 5unlimited permission to copy, distribute and modify it.
9 6
10Basic Installation 7Basic Installation
11================== 8==================
12 9
13Briefly, the shell commands `./configure; make; make install' should 10 These are generic installation instructions.
14configure, build, and install this package. The following
15more-detailed instructions are generic; see the `README' file for
16instructions specific to this package.
17 11
18 The `configure' shell script attempts to guess correct values for 12 The `configure' shell script attempts to guess correct values for
19various system-dependent variables used during compilation. It uses 13various system-dependent variables used during compilation. It uses
@@ -26,9 +20,9 @@ debugging `configure').
26 20
27 It can also use an optional file (typically called `config.cache' 21 It can also use an optional file (typically called `config.cache'
28and enabled with `--cache-file=config.cache' or simply `-C') that saves 22and enabled with `--cache-file=config.cache' or simply `-C') that saves
29the results of its tests to speed up reconfiguring. Caching is 23the results of its tests to speed up reconfiguring. (Caching is
30disabled by default to prevent problems with accidental use of stale 24disabled by default to prevent problems with accidental use of stale
31cache files. 25cache files.)
32 26
33 If you need to do unusual things to compile the package, please try 27 If you need to do unusual things to compile the package, please try
34to figure out how `configure' could check whether to do them, and mail 28to figure out how `configure' could check whether to do them, and mail
@@ -38,17 +32,20 @@ some point `config.cache' contains results you don't want to keep, you
38may remove or edit it. 32may remove or edit it.
39 33
40 The file `configure.ac' (or `configure.in') is used to create 34 The file `configure.ac' (or `configure.in') is used to create
41`configure' by a program called `autoconf'. You need `configure.ac' if 35`configure' by a program called `autoconf'. You only need
42you want to change it or regenerate `configure' using a newer version 36`configure.ac' if you want to change it or regenerate `configure' using
43of `autoconf'. 37a newer version of `autoconf'.
44 38
45The simplest way to compile this package is: 39The simplest way to compile this package is:
46 40
47 1. `cd' to the directory containing the package's source code and type 41 1. `cd' to the directory containing the package's source code and type
48 `./configure' to configure the package for your system. 42 `./configure' to configure the package for your system. If you're
43 using `csh' on an old version of System V, you might need to type
44 `sh ./configure' instead to prevent `csh' from trying to execute
45 `configure' itself.
49 46
50 Running `configure' might take a while. While running, it prints 47 Running `configure' takes awhile. While running, it prints some
51 some messages telling which features it is checking for. 48 messages telling which features it is checking for.
52 49
53 2. Type `make' to compile the package. 50 2. Type `make' to compile the package.
54 51
@@ -70,49 +67,51 @@ The simplest way to compile this package is:
70Compilers and Options 67Compilers and Options
71===================== 68=====================
72 69
73Some systems require unusual options for compilation or linking that the 70 Some systems require unusual options for compilation or linking that
74`configure' script does not know about. Run `./configure --help' for 71the `configure' script does not know about. Run `./configure --help'
75details on some of the pertinent environment variables. 72for details on some of the pertinent environment variables.
76 73
77 You can give `configure' initial values for configuration parameters 74 You can give `configure' initial values for configuration parameters
78by setting variables in the command line or in the environment. Here 75by setting variables in the command line or in the environment. Here
79is an example: 76is an example:
80 77
81 ./configure CC=c99 CFLAGS=-g LIBS=-lposix 78 ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
82 79
83 *Note Defining Variables::, for more details. 80 *Note Defining Variables::, for more details.
84 81
85Compiling For Multiple Architectures 82Compiling For Multiple Architectures
86==================================== 83====================================
87 84
88You can compile the package for more than one kind of computer at the 85 You can compile the package for more than one kind of computer at the
89same time, by placing the object files for each architecture in their 86same time, by placing the object files for each architecture in their
90own directory. To do this, you can use GNU `make'. `cd' to the 87own directory. To do this, you must use a version of `make' that
88supports the `VPATH' variable, such as GNU `make'. `cd' to the
91directory where you want the object files and executables to go and run 89directory where you want the object files and executables to go and run
92the `configure' script. `configure' automatically checks for the 90the `configure' script. `configure' automatically checks for the
93source code in the directory that `configure' is in and in `..'. 91source code in the directory that `configure' is in and in `..'.
94 92
95 With a non-GNU `make', it is safer to compile the package for one 93 If you have to use a `make' that does not support the `VPATH'
96architecture at a time in the source code directory. After you have 94variable, you have to compile the package for one architecture at a
97installed the package for one architecture, use `make distclean' before 95time in the source code directory. After you have installed the
98reconfiguring for another architecture. 96package for one architecture, use `make distclean' before reconfiguring
97for another architecture.
99 98
100Installation Names 99Installation Names
101================== 100==================
102 101
103By default, `make install' installs the package's commands under 102 By default, `make install' will install the package's files in
104`/usr/local/bin', include files under `/usr/local/include', etc. You 103`/usr/local/bin', `/usr/local/man', etc. You can specify an
105can specify an installation prefix other than `/usr/local' by giving 104installation prefix other than `/usr/local' by giving `configure' the
106`configure' the option `--prefix=PREFIX'. 105option `--prefix=PATH'.
107 106
108 You can specify separate installation prefixes for 107 You can specify separate installation prefixes for
109architecture-specific files and architecture-independent files. If you 108architecture-specific files and architecture-independent files. If you
110pass the option `--exec-prefix=PREFIX' to `configure', the package uses 109give `configure' the option `--exec-prefix=PATH', the package will use
111PREFIX as the prefix for installing programs and libraries. 110PATH as the prefix for installing programs and libraries.
112Documentation and other data files still use the regular prefix. 111Documentation and other data files will still use the regular prefix.
113 112
114 In addition, if you use an unusual directory layout you can give 113 In addition, if you use an unusual directory layout you can give
115options like `--bindir=DIR' to specify different values for particular 114options like `--bindir=PATH' to specify different values for particular
116kinds of files. Run `configure --help' for a list of the directories 115kinds of files. Run `configure --help' for a list of the directories
117you can set and what kinds of files go in them. 116you can set and what kinds of files go in them.
118 117
@@ -123,7 +122,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
123Optional Features 122Optional Features
124================= 123=================
125 124
126Some packages pay attention to `--enable-FEATURE' options to 125 Some packages pay attention to `--enable-FEATURE' options to
127`configure', where FEATURE indicates an optional part of the package. 126`configure', where FEATURE indicates an optional part of the package.
128They may also pay attention to `--with-PACKAGE' options, where PACKAGE 127They may also pay attention to `--with-PACKAGE' options, where PACKAGE
129is something like `gnu-as' or `x' (for the X Window System). The 128is something like `gnu-as' or `x' (for the X Window System). The
@@ -138,11 +137,11 @@ you can use the `configure' options `--x-includes=DIR' and
138Specifying the System Type 137Specifying the System Type
139========================== 138==========================
140 139
141There may be some features `configure' cannot figure out automatically, 140 There may be some features `configure' cannot figure out
142but needs to determine by the type of machine the package will run on. 141automatically, but needs to determine by the type of machine the package
143Usually, assuming the package is built to be run on the _same_ 142will run on. Usually, assuming the package is built to be run on the
144architectures, `configure' can figure that out, but if it prints a 143_same_ architectures, `configure' can figure that out, but if it prints
145message saying it cannot guess the machine type, give it the 144a message saying it cannot guess the machine type, give it the
146`--build=TYPE' option. TYPE can either be a short name for the system 145`--build=TYPE' option. TYPE can either be a short name for the system
147type, such as `sun4', or a canonical name which has the form: 146type, such as `sun4', or a canonical name which has the form:
148 147
@@ -157,7 +156,7 @@ where SYSTEM can have one of these forms:
157need to know the machine type. 156need to know the machine type.
158 157
159 If you are _building_ compiler tools for cross-compiling, you should 158 If you are _building_ compiler tools for cross-compiling, you should
160use the option `--target=TYPE' to select the type of system they will 159use the `--target=TYPE' option to select the type of system they will
161produce code for. 160produce code for.
162 161
163 If you want to _use_ a cross compiler, that generates code for a 162 If you want to _use_ a cross compiler, that generates code for a
@@ -168,9 +167,9 @@ eventually be run) with `--host=TYPE'.
168Sharing Defaults 167Sharing Defaults
169================ 168================
170 169
171If you want to set default values for `configure' scripts to share, you 170 If you want to set default values for `configure' scripts to share,
172can create a site shell script called `config.site' that gives default 171you can create a site shell script called `config.site' that gives
173values for variables like `CC', `cache_file', and `prefix'. 172default values for variables like `CC', `cache_file', and `prefix'.
174`configure' looks for `PREFIX/share/config.site' if it exists, then 173`configure' looks for `PREFIX/share/config.site' if it exists, then
175`PREFIX/etc/config.site' if it exists. Or, you can set the 174`PREFIX/etc/config.site' if it exists. Or, you can set the
176`CONFIG_SITE' environment variable to the location of the site script. 175`CONFIG_SITE' environment variable to the location of the site script.
@@ -179,7 +178,7 @@ A warning: not all `configure' scripts look for a site script.
179Defining Variables 178Defining Variables
180================== 179==================
181 180
182Variables not defined in a site shell script can be set in the 181 Variables not defined in a site shell script can be set in the
183environment passed to `configure'. However, some packages may run 182environment passed to `configure'. However, some packages may run
184configure again during the build, and the customized values of these 183configure again during the build, and the customized values of these
185variables may be lost. In order to avoid this problem, you should set 184variables may be lost. In order to avoid this problem, you should set
@@ -187,18 +186,14 @@ them in the `configure' command line, using `VAR=value'. For example:
187 186
188 ./configure CC=/usr/local2/bin/gcc 187 ./configure CC=/usr/local2/bin/gcc
189 188
190causes the specified `gcc' to be used as the C compiler (unless it is 189will cause the specified gcc to be used as the C compiler (unless it is
191overridden in the site shell script). 190overridden in the site shell script).
192 191
193Unfortunately, this technique does not work for `CONFIG_SHELL' due to
194an Autoconf bug. Until the bug is fixed you can use this workaround:
195
196 CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
197
198`configure' Invocation 192`configure' Invocation
199====================== 193======================
200 194
201`configure' recognizes the following options to control how it operates. 195 `configure' recognizes the following options to control how it
196operates.
202 197
203`--help' 198`--help'
204`-h' 199`-h'
diff --git a/README b/README
index ff7da70e..66c6edc5 100644
--- a/README
+++ b/README
@@ -1,6 +1,36 @@
1Run "autoreconf -fi" to create configure. 1About
2=====
2 3
3This is still alpha software. Below we list things that should be 4libmicrohttpd is a library written in C that provides a compact
5API and implementation of an HTTP 1.1 web server. libmicrohttpd
6only implements the HTTP 1.1 protocol. The main application must
7still provide the content.
8
9
10Installation
11============
12
13If you are using Subversion, run "autoreconf -fi" to create configure.
14
15In order to run the testcases, you need a recent version of libcurl.
16libcurl is not required if you just want to install the library.
17
18
19Configure options
20=================
21
22Especially for development, use "--enable-messages" to enable error
23reporting (and use MHD_USE_DEBUG). Error reporting is not enabled by
24default to reduce the size of the library (error messages take
25space!). If you are concerned about space, you should set "CFLAGS" to
26"-Os --fomit-frame-pointer" to have gcc generate tight code. The
27resulting binary should be less than 25k (on x86).
28
29
30Development Status
31==================
32
33This is a beta release. Below we list things that should be
4implemented (in order of importance) before we can claim to be 34implemented (in order of importance) before we can claim to be
5reasonably complete. #XXXX refers to the respective Mantis bug report 35reasonably complete. #XXXX refers to the respective Mantis bug report
6(or feature request). ARCH indicates that implementing this feature 36(or feature request). ARCH indicates that implementing this feature
diff --git a/configure.ac b/configure.ac
index 1db29b83..8178c479 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,7 +34,7 @@ AC_PROG_INSTALL
34AC_PROG_LN_S 34AC_PROG_LN_S
35AC_PROG_MAKE_SET 35AC_PROG_MAKE_SET
36AC_CANONICAL_HOST 36AC_CANONICAL_HOST
37AM_PROG_LIBTOOL 37AC_PROG_LIBTOOL
38 38
39# set GCC options 39# set GCC options
40# use '-fno-strict-aliasing', but only if the compiler can take it 40# use '-fno-strict-aliasing', but only if the compiler can take it
@@ -49,44 +49,54 @@ case "$host_os" in
49 AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system]) 49 AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system])
50 CFLAGS="-no-cpp-precomp $CFLAGS" 50 CFLAGS="-no-cpp-precomp $CFLAGS"
51 LDFLAGS="-flat_namespace -undefined suppress $LDFLAGS" 51 LDFLAGS="-flat_namespace -undefined suppress $LDFLAGS"
52 AM_CONDITIONAL(HAVE_GNU_LD, false)
52 ;; 53 ;;
53linux*) 54linux*)
54 AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system]) 55 AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
56 AM_CONDITIONAL(HAVE_GNU_LD, true)
55 ;; 57 ;;
56freebsd*) 58freebsd*)
57 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 59 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
58 AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system]) 60 AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
61 AM_CONDITIONAL(HAVE_GNU_LD, true)
59 CFLAGS="-D_THREAD_SAFE $CFLAGS" 62 CFLAGS="-D_THREAD_SAFE $CFLAGS"
60 ;; 63 ;;
61openbsd*) 64openbsd*)
62 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 65 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
63 AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system]) 66 AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
67 AM_CONDITIONAL(HAVE_GNU_LD, true)
64 ;; 68 ;;
65netbsd*) 69netbsd*)
66 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 70 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
67 AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system]) 71 AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
72 AM_CONDITIONAL(HAVE_GNU_LD, true)
68 ;; 73 ;;
69*solaris*) 74*solaris*)
70 AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system]) 75 AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
71 AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno doesnt work]) 76 AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno doesnt work])
77 AM_CONDITIONAL(HAVE_GNU_LD, false)
72 ;; 78 ;;
73*arm-linux*) 79*arm-linux*)
74 AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system]) 80 AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
75 CFLAGS="-D_REENTRANT -fPIC -pipe $CFLAGS" 81 CFLAGS="-D_REENTRANT -fPIC -pipe $CFLAGS"
82 AM_CONDITIONAL(HAVE_GNU_LD, true)
76 ;; 83 ;;
77*cygwin*) 84*cygwin*)
78 AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system]) 85 AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
79 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system]) 86 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
87 AM_CONDITIONAL(HAVE_GNU_LD, false)
80 LDFLAGS="$LDFLAGS -no-undefined" 88 LDFLAGS="$LDFLAGS -no-undefined"
81 ;; 89 ;;
82*mingw*) 90*mingw*)
83 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system]) 91 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
84 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system]) 92 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
85 LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32 -lplibc" 93 LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32 -lplibc"
94 AM_CONDITIONAL(HAVE_GNU_LD, true)
86 ;; 95 ;;
87*) 96*)
88 AC_MSG_RESULT(Unrecognised OS $host_os) 97 AC_MSG_RESULT(Unrecognised OS $host_os)
89 AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS]) 98 AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
99 AM_CONDITIONAL(HAVE_GNU_LD, false)
90;; 100;;
91esac 101esac
92 102
@@ -96,12 +106,6 @@ AC_SUBST(PTHREAD_LIBS)
96AC_SUBST(PTHREAD_LDFLAGS) 106AC_SUBST(PTHREAD_LDFLAGS)
97AC_SUBST(PTHREAD_CPPFLAGS) 107AC_SUBST(PTHREAD_CPPFLAGS)
98 108
99# pthread_t is a struct since 11/2004
100AC_CHECK_MEMBER(pthread_t.p, AC_DEFINE(HAVE_NEW_PTHREAD_T, 1,
101 [Define if you have a post 11/2004 pthread library]), , [#include <pthread.h>])
102
103AC_CHECK_FUNCS(pthread_equal)
104
105# Check for headers that are ALWAYS required 109# Check for headers that are ALWAYS required
106AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h pthread.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files])) 110AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h pthread.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files]))
107 111
@@ -117,6 +121,20 @@ LIBS=$SAVE_LIBS
117AC_SYS_LARGEFILE 121AC_SYS_LARGEFILE
118AC_FUNC_FSEEKO 122AC_FUNC_FSEEKO
119 123
124
125# optional: have error messages?
126AC_MSG_CHECKING(--enable-messages argument)
127AC_ARG_ENABLE(messages,
128 [ --enable-messages Enable MHD error messages],
129 [enable_messages=$enableval],
130 [enable_messages="no"])
131AC_MSG_RESULT($enable_messages)
132if test "$enable_messages" = "yes"
133then
134 AC_DEFINE([HAVE_MESSAGES],[1],[Include error messages])
135fi
136
137
120AC_SUBST(CPPFLAGS) 138AC_SUBST(CPPFLAGS)
121AC_SUBST(LIBS) 139AC_SUBST(LIBS)
122AC_SUBST(LDFLAGS) 140AC_SUBST(LDFLAGS)
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index 7a4696fc..c9b73287 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -2,11 +2,17 @@ SUBDIRS = .
2 2
3INCLUDES = -I$(top_srcdir)/src/include 3INCLUDES = -I$(top_srcdir)/src/include
4 4
5if HAVE_GNU_LD
6 retaincommand=-Wl,--retain-symbols-file -Wl,SYMBOLS
7endif
8
9EXTRA_DIST = SYMBOLS
10
5lib_LTLIBRARIES = \ 11lib_LTLIBRARIES = \
6 libmicrohttpd.la 12 libmicrohttpd.la
7 13
8libmicrohttpd_la_LDFLAGS = \ 14libmicrohttpd_la_LDFLAGS = \
9 -export-dynamic -version-info 2:0:0 15 -export-dynamic -version-info 2:0:0 $(retaincommand)
10libmicrohttpd_la_SOURCES = \ 16libmicrohttpd_la_SOURCES = \
11 connection.c connection.h \ 17 connection.c connection.h \
12 daemon.c \ 18 daemon.c \
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
index 48f93dfd..01163154 100644
--- a/src/daemon/connection.c
+++ b/src/daemon/connection.c
@@ -221,9 +221,11 @@ ready_response (struct MHD_Connection *connection)
221 if (ret == -1) 221 if (ret == -1)
222 { 222 {
223 /* end of message, signal other side by closing! */ 223 /* end of message, signal other side by closing! */
224#if DEBUG_CLOSE 224#if DEBUG_CLOSE
225#if HAVE_MESSAGES
225 MHD_DLOG (connection->daemon, "Closing connection (end of response)\n"); 226 MHD_DLOG (connection->daemon, "Closing connection (end of response)\n");
226#endif 227#endif
228#endif
227 response->total_size = connection->messagePos; 229 response->total_size = connection->messagePos;
228 connection_close_error (connection); 230 connection_close_error (connection);
229 return MHD_NO; 231 return MHD_NO;
@@ -335,8 +337,10 @@ MHD_excessive_data_handler (struct MHD_Connection *connection,
335 connection->read_close = MHD_YES; 337 connection->read_close = MHD_YES;
336 connection->headersReceived = MHD_YES; 338 connection->headersReceived = MHD_YES;
337 connection->bodyReceived = MHD_YES; 339 connection->bodyReceived = MHD_YES;
340#if HAVE_MESSAGES
338 MHD_DLOG (connection->daemon, 341 MHD_DLOG (connection->daemon,
339 "Received excessively long header, closing connection.\n"); 342 "Received excessively long header, closing connection.\n");
343#endif
340 response = MHD_create_response_from_data (strlen (REQUEST_TOO_BIG), 344 response = MHD_create_response_from_data (strlen (REQUEST_TOO_BIG),
341 REQUEST_TOO_BIG, MHD_NO, MHD_NO); 345 REQUEST_TOO_BIG, MHD_NO, MHD_NO);
342 MHD_queue_response (connection, status_code, response); 346 MHD_queue_response (connection, status_code, response);
@@ -413,8 +417,10 @@ MHD_connection_add_header (struct MHD_Connection *connection,
413 sizeof (struct MHD_HTTP_Header), MHD_YES); 417 sizeof (struct MHD_HTTP_Header), MHD_YES);
414 if (hdr == NULL) 418 if (hdr == NULL)
415 { 419 {
420#if HAVE_MESSAGES
416 MHD_DLOG (connection->daemon, 421 MHD_DLOG (connection->daemon,
417 "Not enough memory to allocate header record!\n"); 422 "Not enough memory to allocate header record!\n");
423#endif
418 MHD_excessive_data_handler (connection, 424 MHD_excessive_data_handler (connection,
419 MHD_HTTP_REQUEST_ENTITY_TOO_LARGE); 425 MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
420 return MHD_NO; 426 return MHD_NO;
@@ -481,7 +487,9 @@ MHD_parse_cookie_header (struct MHD_Connection *connection)
481 cpy = MHD_pool_allocate (connection->pool, strlen (hdr) + 1, MHD_YES); 487 cpy = MHD_pool_allocate (connection->pool, strlen (hdr) + 1, MHD_YES);
482 if (cpy == NULL) 488 if (cpy == NULL)
483 { 489 {
490#if HAVE_MESSAGES
484 MHD_DLOG (connection->daemon, "Not enough memory to parse cookies!\n"); 491 MHD_DLOG (connection->daemon, "Not enough memory to parse cookies!\n");
492#endif
485 MHD_excessive_data_handler (connection, 493 MHD_excessive_data_handler (connection,
486 MHD_HTTP_REQUEST_ENTITY_TOO_LARGE); 494 MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
487 return MHD_NO; 495 return MHD_NO;
@@ -649,9 +657,11 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
649 { 657 {
650 if (1 != sscanf (clen, "%llu", &cval)) 658 if (1 != sscanf (clen, "%llu", &cval))
651 { 659 {
660#if HAVE_MESSAGES
652 MHD_DLOG (connection->daemon, 661 MHD_DLOG (connection->daemon,
653 "Failed to parse `%s' header `%s', closing connection.\n", 662 "Failed to parse `%s' header `%s', closing connection.\n",
654 MHD_HTTP_HEADER_CONTENT_LENGTH, clen); 663 MHD_HTTP_HEADER_CONTENT_LENGTH, clen);
664#endif
655 goto DIE; 665 goto DIE;
656 } 666 }
657 connection->uploadSize = cval; 667 connection->uploadSize = cval;
@@ -694,9 +704,11 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
694 /* die, http 1.1 request without host and we are pedantic */ 704 /* die, http 1.1 request without host and we are pedantic */
695 connection->bodyReceived = MHD_YES; 705 connection->bodyReceived = MHD_YES;
696 connection->read_close = MHD_YES; 706 connection->read_close = MHD_YES;
707#if HAVE_MESSAGES
697 MHD_DLOG (connection->daemon, 708 MHD_DLOG (connection->daemon,
698 "Received `%s' request without `%s' header.\n", 709 "Received `%s' request without `%s' header.\n",
699 MHD_HTTP_VERSION_1_1, MHD_HTTP_HEADER_HOST); 710 MHD_HTTP_VERSION_1_1, MHD_HTTP_HEADER_HOST);
711#endif
700 response = 712 response =
701 MHD_create_response_from_data (strlen (REQUEST_LACKS_HOST), 713 MHD_create_response_from_data (strlen (REQUEST_LACKS_HOST),
702 REQUEST_LACKS_HOST, MHD_NO, 714 REQUEST_LACKS_HOST, MHD_NO,
@@ -712,8 +724,10 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
712 if (colon == NULL) 724 if (colon == NULL)
713 { 725 {
714 /* error in header line, die hard */ 726 /* error in header line, die hard */
727#if HAVE_MESSAGES
715 MHD_DLOG (connection->daemon, 728 MHD_DLOG (connection->daemon,
716 "Received malformed line (no colon), closing connection.\n"); 729 "Received malformed line (no colon), closing connection.\n");
730#endif
717 goto DIE; 731 goto DIE;
718 } 732 }
719 /* zero-terminate header */ 733 /* zero-terminate header */
@@ -735,8 +749,10 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
735 MHD_parse_cookie_header (connection); 749 MHD_parse_cookie_header (connection);
736 return; 750 return;
737DIE: 751DIE:
752#if HAVE_MESSAGES
738 MHD_DLOG (connection->daemon, 753 MHD_DLOG (connection->daemon,
739 "Closing connection (problem parsing headers)\n"); 754 "Closing connection (problem parsing headers)\n");
755#endif
740 connection_close_error (connection); 756 connection_close_error (connection);
741} 757}
742 758
@@ -785,8 +801,10 @@ MHD_call_connection_handler (struct MHD_Connection *connection)
785 &connection->client_context)) 801 &connection->client_context))
786 { 802 {
787 /* serios internal error, close connection */ 803 /* serios internal error, close connection */
804#if HAVE_MESSAGES
788 MHD_DLOG (connection->daemon, 805 MHD_DLOG (connection->daemon,
789 "Internal application error, closing connection.\n"); 806 "Internal application error, closing connection.\n");
807#endif
790 connection_close_error (connection); 808 connection_close_error (connection);
791 return; 809 return;
792 } 810 }
@@ -831,7 +849,9 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
831 connection->pool = MHD_pool_create (connection->daemon->pool_size); 849 connection->pool = MHD_pool_create (connection->daemon->pool_size);
832 if (connection->pool == NULL) 850 if (connection->pool == NULL)
833 { 851 {
852#if HAVE_MESSAGES
834 MHD_DLOG (connection->daemon, "Failed to create memory pool!\n"); 853 MHD_DLOG (connection->daemon, "Failed to create memory pool!\n");
854#endif
835 connection_close_error (connection); 855 connection_close_error (connection);
836 return MHD_NO; 856 return MHD_NO;
837 } 857 }
@@ -846,8 +866,10 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
846 MHD_BUF_INC_SIZE + 1); 866 MHD_BUF_INC_SIZE + 1);
847 if (tmp == NULL) 867 if (tmp == NULL)
848 { 868 {
869#if HAVE_MESSAGES
849 MHD_DLOG (connection->daemon, 870 MHD_DLOG (connection->daemon,
850 "Not enough memory for reading headers!\n"); 871 "Not enough memory for reading headers!\n");
872#endif
851 MHD_excessive_data_handler (connection, 873 MHD_excessive_data_handler (connection,
852 MHD_HTTP_REQUEST_ENTITY_TOO_LARGE); 874 MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
853 return MHD_NO; 875 return MHD_NO;
@@ -858,7 +880,9 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
858 } 880 }
859 if (connection->readLoc >= connection->read_buffer_size) 881 if (connection->readLoc >= connection->read_buffer_size)
860 { 882 {
883#if HAVE_MESSAGES
861 MHD_DLOG (connection->daemon, "Unexpected call to %s.\n", __FUNCTION__); 884 MHD_DLOG (connection->daemon, "Unexpected call to %s.\n", __FUNCTION__);
885#endif
862 return MHD_NO; 886 return MHD_NO;
863 } 887 }
864 bytes_read = RECV (connection->socket_fd, 888 bytes_read = RECV (connection->socket_fd,
@@ -868,8 +892,10 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
868 { 892 {
869 if (errno == EINTR) 893 if (errno == EINTR)
870 return MHD_NO; 894 return MHD_NO;
895#if HAVE_MESSAGES
871 MHD_DLOG (connection->daemon, 896 MHD_DLOG (connection->daemon,
872 "Failed to receive data: %s\n", STRERROR (errno)); 897 "Failed to receive data: %s\n", STRERROR (errno));
898#endif
873 connection_close_error (connection); 899 connection_close_error (connection);
874 return MHD_YES; 900 return MHD_YES;
875 } 901 }
@@ -880,9 +906,11 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
880 if ((connection->headersReceived == 1) && (connection->readLoc > 0)) 906 if ((connection->headersReceived == 1) && (connection->readLoc > 0))
881 MHD_call_connection_handler (connection); 907 MHD_call_connection_handler (connection);
882#if DEBUG_CLOSE 908#if DEBUG_CLOSE
909#if HAVE_MESSAGES
883 MHD_DLOG (connection->daemon, 910 MHD_DLOG (connection->daemon,
884 "Shutting down connection for reading (other side closed connection)\n"); 911 "Shutting down connection for reading (other side closed connection)\n");
885#endif 912#endif
913#endif
886 shutdown (connection->socket_fd, SHUT_RD); 914 shutdown (connection->socket_fd, SHUT_RD);
887 return MHD_YES; 915 return MHD_YES;
888 } 916 }
@@ -983,7 +1011,9 @@ MHD_build_header_response (struct MHD_Connection *connection)
983 data = MHD_pool_allocate (connection->pool, size + 1, MHD_YES); 1011 data = MHD_pool_allocate (connection->pool, size + 1, MHD_YES);
984 if (data == NULL) 1012 if (data == NULL)
985 { 1013 {
1014#if HAVE_MESSAGES
986 MHD_DLOG (connection->daemon, "Not enough memory for write!\n"); 1015 MHD_DLOG (connection->daemon, "Not enough memory for write!\n");
1016#endif
987 return MHD_NO; 1017 return MHD_NO;
988 } 1018 }
989 memcpy (data, code, off); 1019 memcpy (data, code, off);
@@ -1028,8 +1058,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1028 { 1058 {
1029 if (errno == EINTR) 1059 if (errno == EINTR)
1030 return MHD_YES; 1060 return MHD_YES;
1061#if HAVE_MESSAGES
1031 MHD_DLOG (connection->daemon, 1062 MHD_DLOG (connection->daemon,
1032 "Failed to send data: %s\n", STRERROR (errno)); 1063 "Failed to send data: %s\n", STRERROR (errno));
1064#endif
1033 connection_close_error (connection); 1065 connection_close_error (connection);
1034 return MHD_YES; 1066 return MHD_YES;
1035 } 1067 }
@@ -1044,7 +1076,9 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1044 response = connection->response; 1076 response = connection->response;
1045 if (response == NULL) 1077 if (response == NULL)
1046 { 1078 {
1079#if HAVE_MESSAGES
1047 MHD_DLOG (connection->daemon, "Unexpected call to %s.\n", __FUNCTION__); 1080 MHD_DLOG (connection->daemon, "Unexpected call to %s.\n", __FUNCTION__);
1081#endif
1048 return MHD_NO; 1082 return MHD_NO;
1049 } 1083 }
1050 if (!connection->headersSent) 1084 if (!connection->headersSent)
@@ -1053,8 +1087,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1053 (MHD_NO == MHD_build_header_response (connection))) 1087 (MHD_NO == MHD_build_header_response (connection)))
1054 { 1088 {
1055 /* oops - close! */ 1089 /* oops - close! */
1090#if HAVE_MESSAGES
1056 MHD_DLOG (connection->daemon, 1091 MHD_DLOG (connection->daemon,
1057 "Closing connection (failed to create response header)\n"); 1092 "Closing connection (failed to create response header)\n");
1093#endif
1058 connection_close_error (connection); 1094 connection_close_error (connection);
1059 return MHD_NO; 1095 return MHD_NO;
1060 } 1096 }
@@ -1065,8 +1101,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1065 { 1101 {
1066 if (errno == EINTR) 1102 if (errno == EINTR)
1067 return MHD_YES; 1103 return MHD_YES;
1104#if HAVE_MESSAGES
1068 MHD_DLOG (connection->daemon, 1105 MHD_DLOG (connection->daemon,
1069 "Failed to send data: %s\n", STRERROR (errno)); 1106 "Failed to send data: %s\n", STRERROR (errno));
1107#endif
1070 connection_close_error (connection); 1108 connection_close_error (connection);
1071 return MHD_YES; 1109 return MHD_YES;
1072 } 1110 }
@@ -1114,8 +1152,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1114 { 1152 {
1115 if (errno == EINTR) 1153 if (errno == EINTR)
1116 return MHD_YES; 1154 return MHD_YES;
1155#if HAVE_MESSAGES
1117 MHD_DLOG (connection->daemon, 1156 MHD_DLOG (connection->daemon,
1118 "Failed to send data: %s\n", STRERROR (errno)); 1157 "Failed to send data: %s\n", STRERROR (errno));
1158#endif
1119 connection_close_error (connection); 1159 connection_close_error (connection);
1120 return MHD_YES; 1160 return MHD_YES;
1121 } 1161 }
@@ -1158,9 +1198,11 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1158 if (connection->socket_fd != -1) 1198 if (connection->socket_fd != -1)
1159 { 1199 {
1160#if DEBUG_CLOSE 1200#if DEBUG_CLOSE
1201#if HAVE_MESSAGES
1161 MHD_DLOG (connection->daemon, 1202 MHD_DLOG (connection->daemon,
1162 "Closing connection (http 1.0 or end-of-stream for unknown content length)\n"); 1203 "Closing connection (http 1.0 or end-of-stream for unknown content length)\n");
1163#endif 1204#endif
1205#endif
1164 SHUTDOWN (connection->socket_fd, SHUT_RDWR); 1206 SHUTDOWN (connection->socket_fd, SHUT_RDWR);
1165 CLOSE (connection->socket_fd); 1207 CLOSE (connection->socket_fd);
1166 } 1208 }
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 02cdfe21..d35be3a6 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -72,7 +72,9 @@ MHD_register_handler (struct MHD_Daemon *daemon,
72 ah = malloc (sizeof (struct MHD_Access_Handler)); 72 ah = malloc (sizeof (struct MHD_Access_Handler));
73 if (ah == NULL) 73 if (ah == NULL)
74 { 74 {
75#if HAVE_MESSAGES
75 MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno)); 76 MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
77#endif
76 return MHD_NO; 78 return MHD_NO;
77 } 79 }
78 80
@@ -204,8 +206,10 @@ MHD_handle_connection (void *data)
204 { 206 {
205 if (errno == EINTR) 207 if (errno == EINTR)
206 continue; 208 continue;
209#if HAVE_MESSAGES
207 MHD_DLOG (con->daemon, "Error during select (%d): `%s'\n", 210 MHD_DLOG (con->daemon, "Error during select (%d): `%s'\n",
208 max, STRERROR (errno)); 211 max, STRERROR (errno));
212#endif
209 break; 213 break;
210 } 214 }
211 if (((FD_ISSET (con->socket_fd, &rs)) && 215 if (((FD_ISSET (con->socket_fd, &rs)) &&
@@ -224,9 +228,11 @@ MHD_handle_connection (void *data)
224 if (con->socket_fd != -1) 228 if (con->socket_fd != -1)
225 { 229 {
226#if DEBUG_CLOSE 230#if DEBUG_CLOSE
231#if HAVE_MESSAGES
227 MHD_DLOG (con->daemon, 232 MHD_DLOG (con->daemon,
228 "Processing thread terminating, closing connection\n"); 233 "Processing thread terminating, closing connection\n");
229#endif 234#endif
235#endif
230 SHUTDOWN (con->socket_fd, SHUT_RDWR); 236 SHUTDOWN (con->socket_fd, SHUT_RDWR);
231 CLOSE (con->socket_fd); 237 CLOSE (con->socket_fd);
232 con->socket_fd = -1; 238 con->socket_fd = -1;
@@ -257,7 +263,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
257 s = ACCEPT (daemon->socket_fd, addr, &addrlen); 263 s = ACCEPT (daemon->socket_fd, addr, &addrlen);
258 if ((s < 0) || (addrlen <= 0)) 264 if ((s < 0) || (addrlen <= 0))
259 { 265 {
266#if HAVE_MESSAGES
260 MHD_DLOG (daemon, "Error accepting connection: %s\n", STRERROR (errno)); 267 MHD_DLOG (daemon, "Error accepting connection: %s\n", STRERROR (errno));
268#endif
261 if (s != -1) 269 if (s != -1)
262 { 270 {
263 SHUTDOWN (s, SHUT_RDWR); 271 SHUTDOWN (s, SHUT_RDWR);
@@ -268,8 +276,10 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
268 if (daemon->max_connections == 0) 276 if (daemon->max_connections == 0)
269 { 277 {
270 /* above connection limit - reject */ 278 /* above connection limit - reject */
279#if HAVE_MESSAGES
271 MHD_DLOG (daemon, 280 MHD_DLOG (daemon,
272 "Server reached connection limit (closing inbound connection)\n"); 281 "Server reached connection limit (closing inbound connection)\n");
282#endif
273 SHUTDOWN (s, SHUT_RDWR); 283 SHUTDOWN (s, SHUT_RDWR);
274 CLOSE (s); 284 CLOSE (s);
275 return MHD_NO; 285 return MHD_NO;
@@ -278,8 +288,10 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
278 (MHD_NO == daemon->apc (daemon->apc_cls, addr, addrlen))) 288 (MHD_NO == daemon->apc (daemon->apc_cls, addr, addrlen)))
279 { 289 {
280#if DEBUG_CLOSE 290#if DEBUG_CLOSE
291#if HAVE_MESSAGES
281 MHD_DLOG (daemon, "Connection rejected, closing connection\n"); 292 MHD_DLOG (daemon, "Connection rejected, closing connection\n");
282#endif 293#endif
294#endif
283 SHUTDOWN (s, SHUT_RDWR); 295 SHUTDOWN (s, SHUT_RDWR);
284 CLOSE (s); 296 CLOSE (s);
285 return MHD_YES; 297 return MHD_YES;
@@ -287,7 +299,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
287 connection = malloc (sizeof (struct MHD_Connection)); 299 connection = malloc (sizeof (struct MHD_Connection));
288 if (connection == NULL) 300 if (connection == NULL)
289 { 301 {
302#if HAVE_MESSAGES
290 MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno)); 303 MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
304#endif
291 SHUTDOWN (s, SHUT_RDWR); 305 SHUTDOWN (s, SHUT_RDWR);
292 CLOSE (s); 306 CLOSE (s);
293 return MHD_NO; 307 return MHD_NO;
@@ -297,7 +311,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
297 connection->addr = malloc (addrlen); 311 connection->addr = malloc (addrlen);
298 if (connection->addr == NULL) 312 if (connection->addr == NULL)
299 { 313 {
314#if HAVE_MESSAGES
300 MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno)); 315 MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
316#endif
301 SHUTDOWN (s, SHUT_RDWR); 317 SHUTDOWN (s, SHUT_RDWR);
302 CLOSE (s); 318 CLOSE (s);
303 free (connection); 319 free (connection);
@@ -311,7 +327,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
311 (0 != pthread_create (&connection->pid, 327 (0 != pthread_create (&connection->pid,
312 NULL, &MHD_handle_connection, connection))) 328 NULL, &MHD_handle_connection, connection)))
313 { 329 {
330#if HAVE_MESSAGES
314 MHD_DLOG (daemon, "Failed to create a thread: %s\n", STRERROR (errno)); 331 MHD_DLOG (daemon, "Failed to create a thread: %s\n", STRERROR (errno));
332#endif
315 SHUTDOWN (s, SHUT_RDWR); 333 SHUTDOWN (s, SHUT_RDWR);
316 CLOSE (s); 334 CLOSE (s);
317 free (connection->addr); 335 free (connection->addr);
@@ -356,8 +374,10 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
356 if ((pos->last_activity < timeout) && (pos->socket_fd != -1)) 374 if ((pos->last_activity < timeout) && (pos->socket_fd != -1))
357 { 375 {
358#if DEBUG_CLOSE 376#if DEBUG_CLOSE
377#if HAVE_MESSAGES
359 MHD_DLOG (daemon, "Connection timed out, closing connection\n"); 378 MHD_DLOG (daemon, "Connection timed out, closing connection\n");
360#endif 379#endif
380#endif
361 SHUTDOWN (pos->socket_fd, SHUT_RDWR); 381 SHUTDOWN (pos->socket_fd, SHUT_RDWR);
362 CLOSE (pos->socket_fd); 382 CLOSE (pos->socket_fd);
363 pos->socket_fd = -1; 383 pos->socket_fd = -1;
@@ -508,7 +528,9 @@ MHD_select (struct MHD_Daemon *daemon, int may_block)
508 { 528 {
509 if (errno == EINTR) 529 if (errno == EINTR)
510 return MHD_YES; 530 return MHD_YES;
531#if HAVE_MESSAGES
511 MHD_DLOG (daemon, "Select failed: %s\n", STRERROR (errno)); 532 MHD_DLOG (daemon, "Select failed: %s\n", STRERROR (errno));
533#endif
512 return MHD_NO; 534 return MHD_NO;
513 } 535 }
514 ds = daemon->socket_fd; 536 ds = daemon->socket_fd;
@@ -622,15 +644,20 @@ MHD_start_daemon (unsigned int options,
622 socket_fd = SOCKET (PF_INET, SOCK_STREAM, 0); 644 socket_fd = SOCKET (PF_INET, SOCK_STREAM, 0);
623 if (socket_fd < 0) 645 if (socket_fd < 0)
624 { 646 {
647#if HAVE_MESSAGES
625 if ((options & MHD_USE_DEBUG) != 0) 648 if ((options & MHD_USE_DEBUG) != 0)
626 fprintf (stderr, "Call to socket failed: %s\n", STRERROR (errno)); 649 fprintf (stderr, "Call to socket failed: %s\n", STRERROR (errno));
650#endif
627 return NULL; 651 return NULL;
628 } 652 }
629 if ((SETSOCKOPT (socket_fd, 653 if ((SETSOCKOPT (socket_fd,
630 SOL_SOCKET, 654 SOL_SOCKET,
631 SO_REUSEADDR, 655 SO_REUSEADDR,
632 &on, sizeof (on)) < 0) && (options & MHD_USE_DEBUG) != 0) 656 &on, sizeof (on)) < 0) && (options & MHD_USE_DEBUG) != 0) {
657#if HAVE_MESSAGES
633 fprintf (stderr, "setsockopt failed: %s\n", STRERROR (errno)); 658 fprintf (stderr, "setsockopt failed: %s\n", STRERROR (errno));
659#endif
660 }
634 if ((options & MHD_USE_IPv6) != 0) 661 if ((options & MHD_USE_IPv6) != 0)
635 { 662 {
636 memset (&servaddr6, 0, sizeof (struct sockaddr_in6)); 663 memset (&servaddr6, 0, sizeof (struct sockaddr_in6));
@@ -649,17 +676,21 @@ MHD_start_daemon (unsigned int options,
649 } 676 }
650 if (BIND (socket_fd, servaddr, addrlen) < 0) 677 if (BIND (socket_fd, servaddr, addrlen) < 0)
651 { 678 {
679#if HAVE_MESSAGES
652 if ((options & MHD_USE_DEBUG) != 0) 680 if ((options & MHD_USE_DEBUG) != 0)
653 fprintf (stderr, 681 fprintf (stderr,
654 "Failed to bind to port %u: %s\n", port, STRERROR (errno)); 682 "Failed to bind to port %u: %s\n", port, STRERROR (errno));
683#endif
655 CLOSE (socket_fd); 684 CLOSE (socket_fd);
656 return NULL; 685 return NULL;
657 } 686 }
658 if (LISTEN (socket_fd, 20) < 0) 687 if (LISTEN (socket_fd, 20) < 0)
659 { 688 {
689#if HAVE_MESSAGES
660 if ((options & MHD_USE_DEBUG) != 0) 690 if ((options & MHD_USE_DEBUG) != 0)
661 fprintf (stderr, 691 fprintf (stderr,
662 "Failed to listen for connections: %s\n", STRERROR (errno)); 692 "Failed to listen for connections: %s\n", STRERROR (errno));
693#endif
663 CLOSE (socket_fd); 694 CLOSE (socket_fd);
664 return NULL; 695 return NULL;
665 } 696 }
@@ -697,8 +728,10 @@ MHD_start_daemon (unsigned int options,
697 retVal->notify_completed_cls = va_arg (ap, void *); 728 retVal->notify_completed_cls = va_arg (ap, void *);
698 break; 729 break;
699 default: 730 default:
731#if HAVE_MESSAGES
700 fprintf (stderr, 732 fprintf (stderr,
701 "Invalid MHD_OPTION argument! (Did you terminate the list with MHD_OPTION_END?)\n"); 733 "Invalid MHD_OPTION argument! (Did you terminate the list with MHD_OPTION_END?)\n");
734#endif
702 abort (); 735 abort ();
703 } 736 }
704 } 737 }
@@ -707,8 +740,10 @@ MHD_start_daemon (unsigned int options,
707 (0 != (options & MHD_USE_SELECT_INTERNALLY))) && 740 (0 != (options & MHD_USE_SELECT_INTERNALLY))) &&
708 (0 != pthread_create (&retVal->pid, NULL, &MHD_select_thread, retVal))) 741 (0 != pthread_create (&retVal->pid, NULL, &MHD_select_thread, retVal)))
709 { 742 {
743#if HAVE_MESSAGES
710 MHD_DLOG (retVal, 744 MHD_DLOG (retVal,
711 "Failed to create listen thread: %s\n", STRERROR (errno)); 745 "Failed to create listen thread: %s\n", STRERROR (errno));
746#endif
712 free (retVal); 747 free (retVal);
713 CLOSE (socket_fd); 748 CLOSE (socket_fd);
714 return NULL; 749 return NULL;
@@ -731,8 +766,10 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
731 fd = daemon->socket_fd; 766 fd = daemon->socket_fd;
732 daemon->socket_fd = -1; 767 daemon->socket_fd = -1;
733#if DEBUG_CLOSE 768#if DEBUG_CLOSE
769#if HAVE_MESSAGES
734 MHD_DLOG (daemon, "MHD shutdown, closing listen socket\n"); 770 MHD_DLOG (daemon, "MHD shutdown, closing listen socket\n");
735#endif 771#endif
772#endif
736 CLOSE (fd); 773 CLOSE (fd);
737 if ((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || 774 if ((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
738 (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY))) 775 (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)))
@@ -745,8 +782,10 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
745 if (-1 != daemon->connections->socket_fd) 782 if (-1 != daemon->connections->socket_fd)
746 { 783 {
747#if DEBUG_CLOSE 784#if DEBUG_CLOSE
785#if HAVE_MESSAGES
748 MHD_DLOG (daemon, "MHD shutdown, closing active connections\n"); 786 MHD_DLOG (daemon, "MHD shutdown, closing active connections\n");
749#endif 787#endif
788#endif
750 if (daemon->notify_completed != NULL) 789 if (daemon->notify_completed != NULL)
751 daemon->notify_completed (daemon->notify_completed_cls, 790 daemon->notify_completed (daemon->notify_completed_cls,
752 daemon->connections, 791 daemon->connections,
diff --git a/src/daemon/internal.c b/src/daemon/internal.c
index 85c17b16..433d4886 100644
--- a/src/daemon/internal.c
+++ b/src/daemon/internal.c
@@ -26,7 +26,7 @@
26 26
27#include "internal.h" 27#include "internal.h"
28 28
29 29#if HAVE_MESSAGES
30/** 30/**
31 * fprintf-like helper function for logging debug 31 * fprintf-like helper function for logging debug
32 * messages. 32 * messages.
@@ -42,6 +42,7 @@ MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...)
42 VFPRINTF (stderr, format, va); 42 VFPRINTF (stderr, format, va);
43 va_end (va); 43 va_end (va);
44} 44}
45#endif
45 46
46/** 47/**
47 * Process escape sequences ('+'=space, %HH) 48 * Process escape sequences ('+'=space, %HH)
diff --git a/src/daemon/internal.h b/src/daemon/internal.h
index 3f3f91b0..1596e8df 100644
--- a/src/daemon/internal.h
+++ b/src/daemon/internal.h
@@ -59,11 +59,13 @@
59 */ 59 */
60#define MHD_BUF_INC_SIZE 2048 60#define MHD_BUF_INC_SIZE 2048
61 61
62#if HAVE_MESSAGES
62/** 63/**
63 * fprintf-like helper function for logging debug 64 * fprintf-like helper function for logging debug
64 * messages. 65 * messages.
65 */ 66 */
66void MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...); 67void MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...);
68#endif
67 69
68/** 70/**
69 * Process escape sequences ('+'=space, %HH). 71 * Process escape sequences ('+'=space, %HH).
diff --git a/src/daemon/memorypool.c b/src/daemon/memorypool.c
index 4a183bcb..1721fcfe 100644
--- a/src/daemon/memorypool.c
+++ b/src/daemon/memorypool.c
@@ -25,7 +25,7 @@
25 25
26#include "memorypool.h" 26#include "memorypool.h"
27 27
28// define MAP_ANONYMOUS for Mac OS X 28/* define MAP_ANONYMOUS for Mac OS X */
29#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) 29#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
30#define MAP_ANONYMOUS MAP_ANON 30#define MAP_ANONYMOUS MAP_ANON
31#endif 31#endif