|
GNU libmicrohttpd 1.0.9
|
The environment-driven daemon option matrix shared by the tests. More...
#include "platform.h"#include <microhttpd.h>#include <stdlib.h>#include <string.h>#include <stdio.h>#include "mhd_opt_matrix.h"
Go to the source code of this file.
Macros | |
| #define | NUM_PROFILES ((unsigned int) (sizeof(opt_profiles) / sizeof(opt_profiles[0]))) |
Functions | |
| unsigned int | mhd_opt_matrix_num_profiles (void) |
| const struct MHD_OptMatrixProfile * | mhd_opt_matrix_profile (unsigned int idx) |
| const struct MHD_OptMatrixProfile * | mhd_opt_matrix_lookup (const char *name_or_idx) |
| static int | parse_threading (const char *s, enum MHD_OptMatrixThreading *out) |
| static int | parse_poll (const char *s, enum MHD_OptMatrixPoll *out) |
| static _MHD_NORETURN void | env_error (const char *name, const char *value) |
| const struct MHD_OptMatrixProfile * | mhd_opt_matrix_from_env (void) |
| int | mhd_opt_matrix_effective_discipline (const struct MHD_OptMatrixProfile *prof) |
| int | mhd_opt_matrix_profile_supported (const struct MHD_OptMatrixProfile *prof) |
| const char * | mhd_opt_matrix_describe (const struct MHD_OptMatrixProfile *prof, char *buf, size_t buf_size) |
| unsigned int | mhd_opt_matrix_fill_options (const struct MHD_OptMatrixProfile *prof, struct MHD_OptionItem *ops, unsigned int max_ops) |
| unsigned int | mhd_opt_matrix_daemon_flags (const struct MHD_OptMatrixProfile *prof, unsigned int base_flags, int allow_external) |
| int | mhd_opt_matrix_is_external (const struct MHD_OptMatrixProfile *prof) |
| int | mhd_opt_matrix_raise_mem_limit (struct MHD_OptMatrixProfile *prof, size_t min_limit) |
| void | mhd_opt_matrix_print_notice (const char *test_name) |
Variables | |
| static const struct MHD_OptMatrixProfile | opt_profiles [] |
| static int | env_parsed |
| static int | env_selected |
| static struct MHD_OptMatrixProfile | env_profile |
| static char | env_profile_name [64] |
The environment-driven daemon option matrix shared by the tests.
Definition in file mhd_opt_matrix.c.
| #define NUM_PROFILES ((unsigned int) (sizeof(opt_profiles) / sizeof(opt_profiles[0]))) |
The number of built-in profiles.
Definition at line 96 of file mhd_opt_matrix.c.
Referenced by mhd_opt_matrix_lookup(), mhd_opt_matrix_num_profiles(), and mhd_opt_matrix_profile().
|
static |
Report a broken environment variable and terminate: a typo in a driver script must not silently produce a run with the default configuration.
| name | the name of the variable |
| value | the offending value |
Definition at line 215 of file mhd_opt_matrix.c.
References MHD_OptMatrixProfile::name, and NULL.
Referenced by mhd_opt_matrix_from_env().

| unsigned int mhd_opt_matrix_daemon_flags | ( | const struct MHD_OptMatrixProfile * | prof, |
| unsigned int | base_flags, | ||
| int | allow_external ) |
Combine the daemon flags required by prof with base_flags.
| prof | the profile to apply, may be NULL (base_flags is returned) |
| base_flags | the flags the caller wants in any case, e.g. MHD_USE_ERROR_LOG |
| allow_external | if zero, a profile that asks for external polling is served with an internal polling thread instead; use this in tests whose client cannot call MHD_run() |
Definition at line 458 of file mhd_opt_matrix.c.
References MHD_OPT_MATRIX_POLL_EPOLL, MHD_OPT_MATRIX_POLL_POLL, MHD_OPT_MATRIX_POLL_SELECT, MHD_OPT_MATRIX_THR_EXTERNAL, MHD_OPT_MATRIX_THR_INTERNAL, MHD_OPT_MATRIX_THR_PER_CONNECTION, MHD_OPT_MATRIX_THR_POOL, MHD_USE_EPOLL, MHD_USE_INTERNAL_POLLING_THREAD, MHD_USE_POLL, MHD_USE_THREAD_PER_CONNECTION, NULL, MHD_OptMatrixProfile::poll_backend, and MHD_OptMatrixProfile::threading.
| const char * mhd_opt_matrix_describe | ( | const struct MHD_OptMatrixProfile * | prof, |
| char * | buf, | ||
| size_t | buf_size ) |
Render a one-line, human readable description of prof.
| prof | the profile to describe | |
| [out] | buf | the buffer to write to |
| buf_size | the size of buf |
Definition at line 367 of file mhd_opt_matrix.c.
References MHD_OptMatrixProfile::discipline_lvl, MHD_OptMatrixProfile::mem_limit, mhd_opt_matrix_effective_discipline(), MHD_OPT_MATRIX_THR_POOL, MHD_OptMatrixProfile::name, NULL, MHD_OptMatrixProfile::poll_backend, MHD_OptMatrixProfile::thread_pool_size, MHD_OptMatrixProfile::threading, and MHD_OptMatrixProfile::use_legacy_strict.
Referenced by mhd_opt_matrix_print_notice().


| int mhd_opt_matrix_effective_discipline | ( | const struct MHD_OptMatrixProfile * | prof | ) |
Get the client discipline level that MHD will really use for prof.
This is not always prof->discipline_lvl: MHD_OPTION_STRICT_FOR_CLIENT only has two settings, and daemon.c:7102-7106 maps every value of -1 or below to level -3 (the most permissive one) and every value of 1 or above to level 1. A caller that decides what a request must do therefore has to ask for the effective level, not for the configured one - a test that believes it asked for "slightly lenient" in fact runs at -3.
| prof | the profile to inspect, may be NULL (0 is returned then) |
Definition at line 323 of file mhd_opt_matrix.c.
References MHD_OptMatrixProfile::discipline_lvl, NULL, and MHD_OptMatrixProfile::use_legacy_strict.
Referenced by mhd_opt_matrix_describe().

| unsigned int mhd_opt_matrix_fill_options | ( | const struct MHD_OptMatrixProfile * | prof, |
| struct MHD_OptionItem * | ops, | ||
| unsigned int | max_ops ) |
Fill ops with the options of prof.
The array is terminated with an MHD_OPTION_END element, so it can be passed to MHD_start_daemon() as
MHD_start_daemon (flags, port, NULL, NULL, ahc, cls,
MHD_OPTION_ARRAY, ops,
... other options ...,
MHD_OPTION_END);
which works for a varargs call just as well as for a call that already uses MHD_OPTION_ARRAY.
| prof | the profile to apply, may be NULL (only MHD_OPTION_END is stored then) | |
| [out] | ops | the array to fill |
| max_ops | the number of elements of ops, at least 4 |
Definition at line 414 of file mhd_opt_matrix.c.
References MHD_OptMatrixProfile::discipline_lvl, MHD_OptMatrixProfile::mem_limit, MHD_OPT_MATRIX_THR_POOL, MHD_OPTION_CLIENT_DISCIPLINE_LVL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, MHD_OPTION_END, MHD_OPTION_STRICT_FOR_CLIENT, MHD_OPTION_THREAD_POOL_SIZE, NULL, MHD_OptionItem::option, MHD_OptionItem::ptr_value, MHD_OptMatrixProfile::thread_pool_size, MHD_OptMatrixProfile::threading, MHD_OptMatrixProfile::use_legacy_strict, and MHD_OptionItem::value.
| const struct MHD_OptMatrixProfile * mhd_opt_matrix_from_env | ( | void | ) |
Get the profile selected by the environment.
Definition at line 227 of file mhd_opt_matrix.c.
References MHD_OptMatrixProfile::discipline_lvl, env_error(), env_parsed, env_profile, env_profile_name, env_selected, MHD_OptMatrixProfile::mem_limit, MHD_OPT_MATRIX_DISCP_ENV, mhd_opt_matrix_lookup(), MHD_OPT_MATRIX_MEM_ENV, MHD_OPT_MATRIX_POLL_ENV, MHD_OPT_MATRIX_PROFILE_ENV, MHD_OPT_MATRIX_STRICT_ENV, MHD_OPT_MATRIX_THR_POOL, MHD_OPT_MATRIX_THREADING_ENV, MHD_OptMatrixProfile::name, NULL, opt_profiles, parse_poll(), parse_threading(), MHD_OptMatrixProfile::poll_backend, MHD_OptMatrixProfile::thread_pool_size, MHD_OptMatrixProfile::threading, and MHD_OptMatrixProfile::use_legacy_strict.
Referenced by mhd_opt_matrix_print_notice().


| int mhd_opt_matrix_is_external | ( | const struct MHD_OptMatrixProfile * | prof | ) |
Check whether prof needs the application to drive MHD_run().
| prof | the profile to check, may be NULL |
Definition at line 499 of file mhd_opt_matrix.c.
References MHD_OPT_MATRIX_THR_EXTERNAL, NULL, and MHD_OptMatrixProfile::threading.
| const struct MHD_OptMatrixProfile * mhd_opt_matrix_lookup | ( | const char * | name_or_idx | ) |
Look up a profile by name or by decimal index.
| name_or_idx | the name ("mem-512") or the index ("4") |
Definition at line 136 of file mhd_opt_matrix.c.
References MHD_OptMatrixProfile::name, NULL, NUM_PROFILES, and opt_profiles.
Referenced by mhd_opt_matrix_from_env().

| unsigned int mhd_opt_matrix_num_profiles | ( | void | ) |
The number of built-in profiles.
Definition at line 122 of file mhd_opt_matrix.c.
References NUM_PROFILES.
| void mhd_opt_matrix_print_notice | ( | const char * | test_name | ) |
Print the one-line notice naming the profile in use and, if a profile is selected, the profile.
| test_name | the name of the calling test, used as the line prefix |
Definition at line 521 of file mhd_opt_matrix.c.
References mhd_opt_matrix_describe(), mhd_opt_matrix_from_env(), MHD_OptMatrixProfile::name, and NULL.

| const struct MHD_OptMatrixProfile * mhd_opt_matrix_profile | ( | unsigned int | idx | ) |
Get the built-in profile number idx.
Profile zero is the "default" profile: the library defaults for every dimension plus one internal polling thread, i.e. the configuration the tests of this directory used before the matrix was introduced.
| idx | the index of the profile, wraps around |
Definition at line 129 of file mhd_opt_matrix.c.
References NUM_PROFILES, and opt_profiles.
| int mhd_opt_matrix_profile_supported | ( | const struct MHD_OptMatrixProfile * | prof | ) |
Check whether prof can be used by this build at run time.
| prof | the profile to check |
Definition at line 339 of file mhd_opt_matrix.c.
References MHD_FEATURE_EPOLL, MHD_FEATURE_POLL, MHD_FEATURE_THREADS, MHD_is_feature_supported(), MHD_OPT_MATRIX_POLL_EPOLL, MHD_OPT_MATRIX_POLL_POLL, MHD_OPT_MATRIX_POLL_SELECT, MHD_OPT_MATRIX_THR_EXTERNAL, MHD_OPT_MATRIX_THR_PER_CONNECTION, MHD_YES, NULL, MHD_OptMatrixProfile::poll_backend, and MHD_OptMatrixProfile::threading.

| int mhd_opt_matrix_raise_mem_limit | ( | struct MHD_OptMatrixProfile * | prof, |
| size_t | min_limit ) |
Raise the connection memory limit of prof to at least min_limit.
Tests that cannot work with a tiny connection pool (because the requests they must send do not fit into it) use this to keep the other dimensions of the matrix while staying functional. The change must be reported in the test output so that the log stays truthful.
| [in,out] | prof | the profile to adjust, must be a caller-owned copy |
| min_limit | the smallest acceptable limit, zero does nothing |
Definition at line 508 of file mhd_opt_matrix.c.
References MHD_OptMatrixProfile::mem_limit, and NULL.
|
static |
Parse the polling backend name.
| s | the name | |
| [out] | out | the parsed backend |
Definition at line 193 of file mhd_opt_matrix.c.
References MHD_OPT_MATRIX_POLL_EPOLL, MHD_OPT_MATRIX_POLL_POLL, and MHD_OPT_MATRIX_POLL_SELECT.
Referenced by mhd_opt_matrix_from_env().

|
static |
Parse the threading mode name.
| s | the name | |
| [out] | out | the parsed mode |
Definition at line 168 of file mhd_opt_matrix.c.
References MHD_OPT_MATRIX_THR_EXTERNAL, MHD_OPT_MATRIX_THR_INTERNAL, MHD_OPT_MATRIX_THR_PER_CONNECTION, and MHD_OPT_MATRIX_THR_POOL.
Referenced by mhd_opt_matrix_from_env().

|
static |
Non-zero once the environment has been read into env_profile.
Definition at line 103 of file mhd_opt_matrix.c.
Referenced by mhd_opt_matrix_from_env().
|
static |
The profile derived from the environment.
Definition at line 113 of file mhd_opt_matrix.c.
Referenced by mhd_opt_matrix_from_env().
|
static |
The name of env_profile.
Definition at line 118 of file mhd_opt_matrix.c.
Referenced by mhd_opt_matrix_from_env().
|
static |
Non-zero if the environment selects a profile at all.
Definition at line 108 of file mhd_opt_matrix.c.
Referenced by mhd_opt_matrix_from_env().
|
static |
The built-in matrix of daemon option profiles.
Every value of every dimension listed in the header appears at least once:
Profile zero is "neutral": it is exactly the configuration the tests of this directory used before the matrix was introduced.
The combination "thread-per-connection + epoll" is deliberately absent: MHD rejects it (daemon.c:8680). External polling is always paired with the select()-style interface, as that is the only one the tests can drive.
Definition at line 54 of file mhd_opt_matrix.c.
Referenced by mhd_opt_matrix_from_env(), mhd_opt_matrix_lookup(), and mhd_opt_matrix_profile().