Table1.1
The default (if no other option is passed) is “external select”. The highest performance can typically be obtained with a thread pool using epoll. Apache Benchmark (ab) was used to compare the performance of select and epoll when using a thread pool and a large number of connections. Figure 1.1 shows the resulting plot from the benchmark.c example, which measures the latency between an incoming request and the completion of the transmission of the response. In this setting, the epoll thread pool with four threads was able to handle more than 45,000 connections per second on loopback (with Apache Benchmark running three processes on the same machine).
Figure 1.1
epoll thread pool with four threads模式最多可以支持45000条连接;
(https://www.gnu.org/software/libmicrohttpd/manual/libmicrohttpd.html)
#include
2.4 不处理SIGPIPE的信号
可由使用者自定义如:
static void catcher (int sig)
{
}
static void ignore_sigpipe ()
{
struct sigaction oldsig;
struct sigaction sig;
sig.sa_handler = &catcher;
sigemptyset (&sig.sa_mask);
#ifdef SA_INTERRUPT
sig.sa_flags = SA_INTERRUPT; /* SunOS */
#else
sig.sa_flags = SA_RESTART;
#endif
if (0 != sigaction (SIGPIPE, &sig, &oldsig))
fprintf (stderr, "Failed to install SIGPIPE handler: %s\n", strerror (errno));
}
To compile MHD on z/OS, extract the archive and run
iconv -f UTF-8 -t IBM-1047 contrib/ascebc > /tmp/ascebc.sh
chmod +x /tmp/ascebc.sh
for n in `find * -type f`
do
/tmp/ascebc.sh $n
done
--disable-curl
disable running testcases using libcurl
--disable-largefile
disable support for 64-bit files
--disable-messages
disable logging of error messages (smaller binary size, not so much fun for debugging)
--disable-https
disable HTTPS support, even if GNUtls is found; this option must be used if eCOS license is desired as an option (in all cases the resulting binary falls under a GNU LGPL-only license)
--disable-postprocessor
do not include the post processor API (results in binary incompatibility)
--disable-dauth
do not include the authentication APIs (results in binary incompatibility)
--disable-epoll
do not include epoll support, even on Linux (minimally smaller binary size, good for testing portability to non-Linux systems)
--enable-coverage
set flags for analysis of code-coverage with gcc/gcov (results in slow, large binaries)
--with-gcrypt=PATH
specifies path to libgcrypt installation
--with-gnutls=PATH
specifies path to libgnutls installation
b Windows平台;
1 MHD_FLAG 和 MHD_OPTION
MHD_start_daemon(unsigned int flags,
uint16_t port,
MHD_AcceptPolicyCallback apc,
void *apc_cls,
MHD_AccessHandlerCallback dh,
void *dh_cls,
...)
的flag为:
enum MHD_FLAG
{
MHD_NO_FLAG = 0,
MHD_USE_ERROR_LOG = 1,
MHD_USE_DEBUG = 1,
MHD_USE_TLS = 2,
MHD_USE_THREAD_PER_CONNECTION = 4,
MHD_USE_INTERNAL_POLLING_THREAD = 8,
...
MHD_USE_EPOLL_INTERNAL_THREAD = MHD_USE_EPOLL | MHD_USE_INTERNAL_POLLING_THREAD,
/** @deprecated */
MHD_USE_EPOLL_INTERNALLY = MHD_USE_EPOLL | MHD_USE_INTERNAL_POLLING_THREAD,
/** @deprecated */
MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY = MHD_USE_EPOLL | MHD_USE_INTERNAL_POLLING_THREAD,
...
/** * Automatically use best available polling function.
* Choice of polling function is also depend on other daemon options.
* If #MHD_USE_INTERNAL_POLLING_THREAD is specified then epoll, poll() or
* select() will be used (listed in decreasing preference order, first
* function available on system will be used).
* If #MHD_USE_THREAD_PER_CONNECTION is specified then poll() or select()
* will be used.
* If those flags are not specified then epoll or select() will be
* used (as the only suitable for MHD_get_fdset()) */
MHD_USE_AUTO = 65536,
/*** Run using an internal thread (or thread pool) with best available on
* system polling function.
* This is combination of #MHD_USE_AUTO and #MHD_USE_INTERNAL_POLLING_THREAD
* flags.*/
MHD_USE_AUTO_INTERNAL_THREAD = MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD
};
MHD_start_daemon(unsigned int flags,
uint16_t port,
MHD_AcceptPolicyCallback apc,
void *apc_cls,
MHD_AccessHandlerCallback dh,
void *dh_cls,
...)
的... 为如下:
enum MHD_OPTION
{
/**
* No more options / last option. This is used
* to terminate the VARARGs list.
*/
MHD_OPTION_END = 0,
...
/**
* Additional options given in an array of `struct MHD_OptionItem`.
* The array must be terminated with an entry `{MHD_OPTION_END, 0, NULL}`.
* An example for code using #MHD_OPTION_ARRAY is:
*
* struct MHD_OptionItem ops[] = {
* { MHD_OPTION_CONNECTION_LIMIT, 100, NULL },
* { MHD_OPTION_CONNECTION_TIMEOUT, 10, NULL },
* { MHD_OPTION_END, 0, NULL }
* };
* d = MHD_start_daemon (0, 8080, NULL, NULL, dh, NULL,
* MHD_OPTION_ARRAY, ops,
* MHD_OPTION_END);
*
* For options that expect a single pointer argument, the
* second member of the `struct MHD_OptionItem` is ignored.
* For options that expect two pointer arguments, the first
* argument must be cast to `intptr_t`.
*/
MHD_OPTION_ARRAY = 15,
...
};
待续...