mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-21 13:16:57 +00:00
MINOR: haproxy: permit to register features during boot
The regtests are using the "feature()" predicate but this one can only rely on build-time options. It would be nice if some runtime-specific options could be detected at boot time so that regtests could more flexibly adapt to what is supported (capabilities, splicing, etc). Similarly, certain features that are currently enabled with USE_XXX could also be automatically detected at build time using ifdefs and would simplify the configuration, but then we'd lose the feature report in the feature list which is convenient for regtests. This patch makes sure that haproxy -vv shows the variable's contents and not the macro's contents, and adds a new hap_register_feature() to allow the code to register a new keyword.
This commit is contained in:
parent
a5e96425a2
commit
90fa2eaa15
@ -25,7 +25,7 @@
|
||||
#include <haproxy/api-t.h>
|
||||
#include <haproxy/global-t.h>
|
||||
|
||||
extern const char *build_features;
|
||||
extern char *build_features;
|
||||
extern struct global global;
|
||||
extern int pid; /* current process id */
|
||||
extern int actconn; /* # of active sessions */
|
||||
@ -60,6 +60,7 @@ void run_poll_loop(void);
|
||||
int tell_old_pids(int sig);
|
||||
int delete_oldpid(int pid);
|
||||
void hap_register_build_opts(const char *str, int must_free);
|
||||
void hap_register_feature(const char *name);
|
||||
int split_version(const char *version, unsigned int *value);
|
||||
int compare_current_version(const char *version);
|
||||
void display_version();
|
||||
|
@ -159,9 +159,9 @@ DECLARE_INIT_STAGES;
|
||||
empty_t __read_mostly_align HA_SECTION("read_mostly") ALIGNED(64);
|
||||
|
||||
#ifdef BUILD_FEATURES
|
||||
const char *build_features = BUILD_FEATURES;
|
||||
char *build_features = BUILD_FEATURES;
|
||||
#else
|
||||
const char *build_features = "";
|
||||
char *build_features = "";
|
||||
#endif
|
||||
|
||||
/* list of config files */
|
||||
@ -333,6 +333,30 @@ void hap_register_build_opts(const char *str, int must_free)
|
||||
LIST_APPEND(&build_opts_list, &b->list);
|
||||
}
|
||||
|
||||
/* used to make a new feature appear in the build_features list at boot time.
|
||||
* The feature must be in the format "XXX" without the leading "+" which will
|
||||
* be automatically appended.
|
||||
*/
|
||||
void hap_register_feature(const char *name)
|
||||
{
|
||||
static int must_free = 0;
|
||||
int new_len = strlen(build_features) + 2 + strlen(name);
|
||||
char *new_features;
|
||||
|
||||
new_features = malloc(new_len + 1);
|
||||
if (!new_features)
|
||||
return;
|
||||
|
||||
strlcpy2(new_features, build_features, new_len);
|
||||
snprintf(new_features, new_len + 1, "%s +%s", build_features, name);
|
||||
|
||||
if (must_free)
|
||||
ha_free(&build_features);
|
||||
|
||||
build_features = new_features;
|
||||
must_free = 1;
|
||||
}
|
||||
|
||||
#define VERSION_MAX_ELTS 7
|
||||
|
||||
/* This function splits an haproxy version string into an array of integers.
|
||||
@ -545,13 +569,11 @@ static void display_build_opts()
|
||||
#ifdef BUILD_DEBUG
|
||||
"\n DEBUG = " BUILD_DEBUG
|
||||
#endif
|
||||
#ifdef BUILD_FEATURES
|
||||
"\n\nFeature list : " BUILD_FEATURES
|
||||
#endif
|
||||
"\n\nFeature list : %s"
|
||||
"\n\nDefault settings :"
|
||||
"\n bufsize = %d, maxrewrite = %d, maxpollevents = %d"
|
||||
"\n\n",
|
||||
BUFSIZE, MAXREWRITE, MAX_POLL_EVENTS);
|
||||
build_features, BUFSIZE, MAXREWRITE, MAX_POLL_EVENTS);
|
||||
|
||||
list_for_each_entry(item, &build_opts_list, list) {
|
||||
puts(item->str);
|
||||
|
Loading…
Reference in New Issue
Block a user