summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-09-09 21:32:12 +0000
committerChristian Grothoff <christian@grothoff.org>2007-09-09 21:32:12 +0000
commitfb36fb2009a35e48be28df422af5a4b42d099cda (patch)
tree103c9372286a794293b36bcc0e18e091bde49f3d
parent8ce09efc5e3c19d413727e8b80c5f2eff9406b38 (diff)
release
-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 @@
+Sun Sep 9 14:32:23 MDT 2007
+ Added option to compile debug/warning messages;
+ error messages are now disabled by default.
+ Modified linker option for GNU LD to not export
+ non-public symbols (further reduces binary size).
+ Releasing libmicrohttpd 0.1.0. - CG
+
Sat Sep 8 21:54:04 MDT 2007
Extended API to allow for incremental POST
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 @@
-Installation Instructions
-*************************
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
+Foundation, Inc.
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006 Free Software Foundation, Inc.
-
-This file is free documentation; the Free Software Foundation gives
+ This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
-Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package. The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.
+ These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
@@ -26,9 +20,9 @@ debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. Caching is
+the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
-cache files.
+cache files.)
If you need to do unusual things to compile the package, please try
to 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
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
+`configure' by a program called `autoconf'. You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system.
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
- Running `configure' might take a while. While running, it prints
- some messages telling which features it is checking for.
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
2. Type `make' to compile the package.
@@ -70,49 +67,51 @@ The simplest way to compile this package is:
Compilers and Options
=====================
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about. Run `./configure --help' for
-details on some of the pertinent environment variables.
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
- ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+ ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
-You can compile the package for more than one kind of computer at the
+ You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
-own directory. To do this, you can use GNU `make'. `cd' to the
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
- With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory. After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
+ If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a
+time in the source code directory. After you have installed the
+package for one architecture, use `make distclean' before reconfiguring
+for another architecture.
Installation Names
==================
-By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc. You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
+options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
@@ -123,7 +122,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
-Some packages pay attention to `--enable-FEATURE' options to
+ Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is 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
Specifying the System Type
==========================
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
@@ -157,7 +156,7 @@ where SYSTEM can have one of these forms:
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
+use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
@@ -168,9 +167,9 @@ eventually be run) with `--host=TYPE'.
Sharing Defaults
================
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`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.
Defining Variables
==================
-Variables not defined in a site shell script can be set in the
+ Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables 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:
./configure CC=/usr/local2/bin/gcc
-causes the specified `gcc' to be used as the C compiler (unless it is
+will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug. Until the bug is fixed you can use this workaround:
-
- CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
`configure' Invocation
======================
-`configure' recognizes the following options to control how it operates.
+ `configure' recognizes the following options to control how it
+operates.
`--help'
`-h'
diff --git a/README b/README
index ff7da70e..66c6edc5 100644
--- a/README
+++ b/README
@@ -1,6 +1,36 @@
-Run "autoreconf -fi" to create configure.
+About
+=====
-This is still alpha software. Below we list things that should be
+libmicrohttpd is a library written in C that provides a compact
+API and implementation of an HTTP 1.1 web server. libmicrohttpd
+only implements the HTTP 1.1 protocol. The main application must
+still provide the content.
+
+
+Installation
+============
+
+If you are using Subversion, run "autoreconf -fi" to create configure.
+
+In order to run the testcases, you need a recent version of libcurl.
+libcurl is not required if you just want to install the library.
+
+
+Configure options
+=================
+
+Especially for development, use "--enable-messages" to enable error
+reporting (and use MHD_USE_DEBUG). Error reporting is not enabled by
+default to reduce the size of the library (error messages take
+space!). If you are concerned about space, you should set "CFLAGS" to
+"-Os --fomit-frame-pointer" to have gcc generate tight code. The
+resulting binary should be less than 25k (on x86).
+
+
+Development Status
+==================
+
+This is a beta release. Below we list things that should be
implemented (in order of importance) before we can claim to be
reasonably complete. #XXXX refers to the respective Mantis bug report
(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
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_CANONICAL_HOST
-AM_PROG_LIBTOOL
+AC_PROG_LIBTOOL
# set GCC options
# use '-fno-strict-aliasing', but only if the compiler can take it
@@ -49,44 +49,54 @@ case "$host_os" in
AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system])
CFLAGS="-no-cpp-precomp $CFLAGS"
LDFLAGS="-flat_namespace -undefined suppress $LDFLAGS"
+ AM_CONDITIONAL(HAVE_GNU_LD, false)
;;
linux*)
AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
+ AM_CONDITIONAL(HAVE_GNU_LD, true)
;;
freebsd*)
AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
+ AM_CONDITIONAL(HAVE_GNU_LD, true)
CFLAGS="-D_THREAD_SAFE $CFLAGS"
;;
openbsd*)
AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
+ AM_CONDITIONAL(HAVE_GNU_LD, true)
;;
netbsd*)
AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
+ AM_CONDITIONAL(HAVE_GNU_LD, true)
;;
*solaris*)
AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno doesnt work])
+ AM_CONDITIONAL(HAVE_GNU_LD, false)
;;
*arm-linux*)
AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
CFLAGS="-D_REENTRANT -fPIC -pipe $CFLAGS"
+ AM_CONDITIONAL(HAVE_GNU_LD, true)
;;
*cygwin*)
AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
+ AM_CONDITIONAL(HAVE_GNU_LD, false)
LDFLAGS="$LDFLAGS -no-undefined"
;;
*mingw*)
AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32 -lplibc"
+ AM_CONDITIONAL(HAVE_GNU_LD, true)
;;
*)
AC_MSG_RESULT(Unrecognised OS $host_os)
AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
+ AM_CONDITIONAL(HAVE_GNU_LD, false)
;;
esac
@@ -96,12 +106,6 @@ AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_LDFLAGS)
AC_SUBST(PTHREAD_CPPFLAGS)
-# pthread_t is a struct since 11/2004
-AC_CHECK_MEMBER(pthread_t.p, AC_DEFINE(HAVE_NEW_PTHREAD_T, 1,
- [Define if you have a post 11/2004 pthread library]), , [#include <pthread.h>])
-
-AC_CHECK_FUNCS(pthread_equal)
-
# Check for headers that are ALWAYS required
AC_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]))
@@ -117,6 +121,20 @@ LIBS=$SAVE_LIBS
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
+
+# optional: have error messages?
+AC_MSG_CHECKING(--enable-messages argument)
+AC_ARG_ENABLE(messages,
+ [ --enable-messages Enable MHD error messages],
+ [enable_messages=$enableval],
+ [enable_messages="no"])
+AC_MSG_RESULT($enable_messages)
+if test "$enable_messages" = "yes"
+then
+ AC_DEFINE([HAVE_MESSAGES],[1],[Include error messages])
+fi
+
+
AC_SUBST(CPPFLAGS)
AC_SUBST(LIBS)
AC_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 = .
INCLUDES = -I$(top_srcdir)/src/include
+if HAVE_GNU_LD
+ retaincommand=-Wl,--retain-symbols-file -Wl,SYMBOLS
+endif
+
+EXTRA_DIST = SYMBOLS
+
lib_LTLIBRARIES = \
libmicrohttpd.la
libmicrohttpd_la_LDFLAGS = \
- -export-dynamic -version-info 2:0:0
+ -export-dynamic -version-info 2:0:0 $(retaincommand)
libmicrohttpd_la_SOURCES = \
connection.c connection.h \
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)
if (ret == -1)
{
/* end of message, signal other side by closing! */
-#if DEBUG_CLOSE
+#if DEBUG_CLOSE
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon, "Closing connection (end of response)\n");
#endif
+#endif
response->total_size = connection->messagePos;
connection_close_error (connection);
return MHD_NO;
@@ -335,8 +337,10 @@ MHD_excessive_data_handler (struct MHD_Connection *connection,
connection->read_close = MHD_YES;
connection->headersReceived = MHD_YES;
connection->bodyReceived = MHD_YES;
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Received excessively long header, closing connection.\n");
+#endif
response = MHD_create_response_from_data (strlen (REQUEST_TOO_BIG),
REQUEST_TOO_BIG, MHD_NO, MHD_NO);
MHD_queue_response (connection, status_code, response);
@@ -413,8 +417,10 @@ MHD_connection_add_header (struct MHD_Connection *connection,
sizeof (struct MHD_HTTP_Header), MHD_YES);
if (hdr == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Not enough memory to allocate header record!\n");
+#endif
MHD_excessive_data_handler (connection,
MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
return MHD_NO;
@@ -481,7 +487,9 @@ MHD_parse_cookie_header (struct MHD_Connection *connection)
cpy = MHD_pool_allocate (connection->pool, strlen (hdr) + 1, MHD_YES);
if (cpy == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon, "Not enough memory to parse cookies!\n");
+#endif
MHD_excessive_data_handler (connection,
MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
return MHD_NO;
@@ -649,9 +657,11 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
{
if (1 != sscanf (clen, "%llu", &cval))
{
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Failed to parse `%s' header `%s', closing connection.\n",
MHD_HTTP_HEADER_CONTENT_LENGTH, clen);
+#endif
goto DIE;
}
connection->uploadSize = cval;
@@ -694,9 +704,11 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
/* die, http 1.1 request without host and we are pedantic */
connection->bodyReceived = MHD_YES;
connection->read_close = MHD_YES;
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Received `%s' request without `%s' header.\n",
MHD_HTTP_VERSION_1_1, MHD_HTTP_HEADER_HOST);
+#endif
response =
MHD_create_response_from_data (strlen (REQUEST_LACKS_HOST),
REQUEST_LACKS_HOST, MHD_NO,
@@ -712,8 +724,10 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
if (colon == NULL)
{
/* error in header line, die hard */
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Received malformed line (no colon), closing connection.\n");
+#endif
goto DIE;
}
/* zero-terminate header */
@@ -735,8 +749,10 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
MHD_parse_cookie_header (connection);
return;
DIE:
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Closing connection (problem parsing headers)\n");
+#endif
connection_close_error (connection);
}
@@ -785,8 +801,10 @@ MHD_call_connection_handler (struct MHD_Connection *connection)
&connection->client_context))
{
/* serios internal error, close connection */
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Internal application error, closing connection.\n");
+#endif
connection_close_error (connection);
return;
}
@@ -831,7 +849,9 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
connection->pool = MHD_pool_create (connection->daemon->pool_size);
if (connection->pool == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon, "Failed to create memory pool!\n");
+#endif
connection_close_error (connection);
return MHD_NO;
}
@@ -846,8 +866,10 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
MHD_BUF_INC_SIZE + 1);
if (tmp == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Not enough memory for reading headers!\n");
+#endif
MHD_excessive_data_handler (connection,
MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
return MHD_NO;
@@ -858,7 +880,9 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
}
if (connection->readLoc >= connection->read_buffer_size)
{
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon, "Unexpected call to %s.\n", __FUNCTION__);
+#endif
return MHD_NO;
}
bytes_read = RECV (connection->socket_fd,
@@ -868,8 +892,10 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
{
if (errno == EINTR)
return MHD_NO;
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Failed to receive data: %s\n", STRERROR (errno));
+#endif
connection_close_error (connection);
return MHD_YES;
}
@@ -880,9 +906,11 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
if ((connection->headersReceived == 1) && (connection->readLoc > 0))
MHD_call_connection_handler (connection);
#if DEBUG_CLOSE
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Shutting down connection for reading (other side closed connection)\n");
#endif
+#endif
shutdown (connection->socket_fd, SHUT_RD);
return MHD_YES;
}
@@ -983,7 +1011,9 @@ MHD_build_header_response (struct MHD_Connection *connection)
data = MHD_pool_allocate (connection->pool, size + 1, MHD_YES);
if (data == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon, "Not enough memory for write!\n");
+#endif
return MHD_NO;
}
memcpy (data, code, off);
@@ -1028,8 +1058,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
{
if (errno == EINTR)
return MHD_YES;
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Failed to send data: %s\n", STRERROR (errno));
+#endif
connection_close_error (connection);
return MHD_YES;
}
@@ -1044,7 +1076,9 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
response = connection->response;
if (response == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon, "Unexpected call to %s.\n", __FUNCTION__);
+#endif
return MHD_NO;
}
if (!connection->headersSent)
@@ -1053,8 +1087,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
(MHD_NO == MHD_build_header_response (connection)))
{
/* oops - close! */
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Closing connection (failed to create response header)\n");
+#endif
connection_close_error (connection);
return MHD_NO;
}
@@ -1065,8 +1101,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
{
if (errno == EINTR)
return MHD_YES;
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Failed to send data: %s\n", STRERROR (errno));
+#endif
connection_close_error (connection);
return MHD_YES;
}
@@ -1114,8 +1152,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
{
if (errno == EINTR)
return MHD_YES;
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Failed to send data: %s\n", STRERROR (errno));
+#endif
connection_close_error (connection);
return MHD_YES;
}
@@ -1158,9 +1198,11 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
if (connection->socket_fd != -1)
{
#if DEBUG_CLOSE
+#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Closing connection (http 1.0 or end-of-stream for unknown content length)\n");
#endif
+#endif
SHUTDOWN (connection->socket_fd, SHUT_RDWR);
CLOSE (connection->socket_fd);
}
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,
ah = malloc (sizeof (struct MHD_Access_Handler));
if (ah == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
+#endif
return MHD_NO;
}
@@ -204,8 +206,10 @@ MHD_handle_connection (void *data)
{
if (errno == EINTR)
continue;
+#if HAVE_MESSAGES
MHD_DLOG (con->daemon, "Error during select (%d): `%s'\n",
max, STRERROR (errno));
+#endif
break;
}
if (((FD_ISSET (con->socket_fd, &rs)) &&
@@ -224,9 +228,11 @@ MHD_handle_connection (void *data)
if (con->socket_fd != -1)
{
#if DEBUG_CLOSE
+#if HAVE_MESSAGES
MHD_DLOG (con->daemon,
"Processing thread terminating, closing connection\n");
#endif
+#endif
SHUTDOWN (con->socket_fd, SHUT_RDWR);
CLOSE (con->socket_fd);
con->socket_fd = -1;
@@ -257,7 +263,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
s = ACCEPT (daemon->socket_fd, addr, &addrlen);
if ((s < 0) || (addrlen <= 0))
{
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "Error accepting connection: %s\n", STRERROR (errno));
+#endif
if (s != -1)
{
SHUTDOWN (s, SHUT_RDWR);
@@ -268,8 +276,10 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
if (daemon->max_connections == 0)
{
/* above connection limit - reject */
+#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Server reached connection limit (closing inbound connection)\n");
+#endif
SHUTDOWN (s, SHUT_RDWR);
CLOSE (s);
return MHD_NO;
@@ -278,8 +288,10 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
(MHD_NO == daemon->apc (daemon->apc_cls, addr, addrlen)))
{
#if DEBUG_CLOSE
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "Connection rejected, closing connection\n");
#endif
+#endif
SHUTDOWN (s, SHUT_RDWR);
CLOSE (s);
return MHD_YES;
@@ -287,7 +299,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
connection = malloc (sizeof (struct MHD_Connection));
if (connection == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
+#endif
SHUTDOWN (s, SHUT_RDWR);
CLOSE (s);
return MHD_NO;
@@ -297,7 +311,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
connection->addr = malloc (addrlen);
if (connection->addr == NULL)
{
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
+#endif
SHUTDOWN (s, SHUT_RDWR);
CLOSE (s);
free (connection);
@@ -311,7 +327,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
(0 != pthread_create (&connection->pid,
NULL, &MHD_handle_connection, connection)))
{
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "Failed to create a thread: %s\n", STRERROR (errno));
+#endif
SHUTDOWN (s, SHUT_RDWR);
CLOSE (s);
free (connection->addr);
@@ -356,8 +374,10 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
if ((pos->last_activity < timeout) && (pos->socket_fd != -1))
{
#if DEBUG_CLOSE
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "Connection timed out, closing connection\n");
#endif
+#endif
SHUTDOWN (pos->socket_fd, SHUT_RDWR);
CLOSE (pos->socket_fd);
pos->socket_fd = -1;
@@ -508,7 +528,9 @@ MHD_select (struct MHD_Daemon *daemon, int may_block)
{
if (errno == EINTR)
return MHD_YES;
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "Select failed: %s\n", STRERROR (errno));
+#endif
return MHD_NO;
}
ds = daemon->socket_fd;
@@ -622,15 +644,20 @@ MHD_start_daemon (unsigned int options,
socket_fd = SOCKET (PF_INET, SOCK_STREAM, 0);
if (socket_fd < 0)
{
+#if HAVE_MESSAGES
if ((options & MHD_USE_DEBUG) != 0)
fprintf (stderr, "Call to socket failed: %s\n", STRERROR (errno));
+#endif
return NULL;
}
if ((SETSOCKOPT (socket_fd,
SOL_SOCKET,
SO_REUSEADDR,
- &on, sizeof (on)) < 0) && (options & MHD_USE_DEBUG) != 0)
+ &on, sizeof (on)) < 0) && (options & MHD_USE_DEBUG) != 0) {
+#if HAVE_MESSAGES
fprintf (stderr, "setsockopt failed: %s\n", STRERROR (errno));
+#endif
+ }
if ((options & MHD_USE_IPv6) != 0)
{
memset (&servaddr6, 0, sizeof (struct sockaddr_in6));
@@ -649,17 +676,21 @@ MHD_start_daemon (unsigned int options,
}
if (BIND (socket_fd, servaddr, addrlen) < 0)
{
+#if HAVE_MESSAGES
if ((options & MHD_USE_DEBUG) != 0)
fprintf (stderr,
"Failed to bind to port %u: %s\n", port, STRERROR (errno));
+#endif
CLOSE (socket_fd);
return NULL;
}
if (LISTEN (socket_fd, 20) < 0)
{
+#if HAVE_MESSAGES
if ((options & MHD_USE_DEBUG) != 0)
fprintf (stderr,
"Failed to listen for connections: %s\n", STRERROR (errno));
+#endif
CLOSE (socket_fd);
return NULL;
}
@@ -697,8 +728,10 @@ MHD_start_daemon (unsigned int options,
retVal->notify_completed_cls = va_arg (ap, void *);
break;
default:
+#if HAVE_MESSAGES
fprintf (stderr,
"Invalid MHD_OPTION argument! (Did you terminate the list with MHD_OPTION_END?)\n");
+#endif
abort ();
}
}
@@ -707,8 +740,10 @@ MHD_start_daemon (unsigned int options,
(0 != (options & MHD_USE_SELECT_INTERNALLY))) &&
(0 != pthread_create (&retVal->pid, NULL, &MHD_select_thread, retVal)))
{
+#if HAVE_MESSAGES
MHD_DLOG (retVal,
"Failed to create listen thread: %s\n", STRERROR (errno));
+#endif
free (retVal);
CLOSE (socket_fd);
return NULL;
@@ -731,8 +766,10 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
fd = daemon->socket_fd;
daemon->socket_fd = -1;
#if DEBUG_CLOSE
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "MHD shutdown, closing listen socket\n");
#endif
+#endif
CLOSE (fd);
if ((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
(0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)))
@@ -745,8 +782,10 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
if (-1 != daemon->connections->socket_fd)
{
#if DEBUG_CLOSE
+#if HAVE_MESSAGES
MHD_DLOG (daemon, "MHD shutdown, closing active connections\n");
#endif
+#endif
if (daemon->notify_completed != NULL)
daemon->notify_completed (daemon->notify_completed_cls,
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 @@
#include "internal.h"
-
+#if HAVE_MESSAGES
/**
* fprintf-like helper function for logging debug
* messages.
@@ -42,6 +42,7 @@ MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...)
VFPRINTF (stderr, format, va);
va_end (va);
}
+#endif
/**
* 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 @@
*/
#define MHD_BUF_INC_SIZE 2048
+#if HAVE_MESSAGES
/**
* fprintf-like helper function for logging debug
* messages.
*/
void MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...);
+#endif
/**
* 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 @@
#include "memorypool.h"
-// define MAP_ANONYMOUS for Mac OS X
+/* define MAP_ANONYMOUS for Mac OS X */
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif