added pcre jit support

This commit is contained in:
Roberto De Ioris
2012-11-09 12:04:13 +01:00
parent 519df88126
commit 0fa2c543ec
3 changed files with 27 additions and 1 deletions
+14 -1
View File
@@ -1,6 +1,17 @@
#ifdef UWSGI_PCRE
#include "uwsgi.h"
extern struct uwsgi_server uwsgi;
void uwsgi_opt_pcre_jit(char *opt, char *value, void *foobar) {
#if defined(PCRE_STUDY_JIT_COMPILE) && defined(PCRE_CONFIG_JIT)
int has_jit = 0, ret;
ret = pcre_config(PCRE_CONFIG_JIT, &has_jit);
if (ret != 0 || has_jit != 1) return;
uwsgi.pcre_jit = PCRE_STUDY_JIT_COMPILE;
#endif
}
int uwsgi_regexp_build(char *re, pcre **pattern, pcre_extra **pattern_extra) {
const char *errstr;
@@ -12,7 +23,9 @@ int uwsgi_regexp_build(char *re, pcre **pattern, pcre_extra **pattern_extra) {
return -1;
}
*pattern_extra = (pcre_extra *) pcre_study((const pcre*)*pattern, 0, &errstr);
int opt = uwsgi.pcre_jit;
*pattern_extra = (pcre_extra *) pcre_study((const pcre*)*pattern, opt, &errstr);
if (*pattern_extra == NULL && errstr != NULL) {
pcre_free(*pattern);
uwsgi_log("pcre (study) error: %s\n", errstr);
+11
View File
@@ -279,6 +279,9 @@ static struct uwsgi_option uwsgi_base_options[] = {
#ifdef MADV_MERGEABLE
{"ksm", optional_argument, 0, "enable Linux KSM", uwsgi_opt_set_int, &uwsgi.linux_ksm, 0},
#endif
#endif
#ifdef UWSGI_PCRE
{"pcre-jit", no_argument, 0, "enable pcre jit (if available)", uwsgi_opt_pcre_jit, NULL, UWSGI_OPT_IMMEDIATE},
#endif
{"never-swap", no_argument, 0, "lock all memory pages avoiding swapping", uwsgi_opt_true, &uwsgi.never_swap, 0},
{"touch-reload", required_argument, 0, "reload uWSGI if the specified file is modified/touched", uwsgi_opt_add_string_list, &uwsgi.touch_reload, UWSGI_OPT_MASTER},
@@ -1906,6 +1909,14 @@ int main(int argc, char *argv[], char *envp[]) {
}
uwsgi_log_initial("clock source: %s\n", uwsgi.clock->name);
#ifdef UWSGI_PCRE
if (uwsgi.pcre_jit) {
uwsgi_log_initial("pcre jit enabled\n");
}
else {
uwsgi_log_initial("pcre jit disabled\n");
}
#endif
#ifdef __BIG_ENDIAN__
uwsgi_log_initial("*** big endian arch detected ***\n");
+2
View File
@@ -1472,6 +1472,7 @@ struct uwsgi_server {
struct uwsgi_string_list *requested_logger;
#ifdef UWSGI_PCRE
int pcre_jit;
struct uwsgi_regexp_list *log_drain_rules;
struct uwsgi_regexp_list *log_filter_rules;
struct uwsgi_regexp_list *log_route;
@@ -2986,6 +2987,7 @@ void uwsgi_opt_set_str_spaced(char *, char *, void *);
void uwsgi_opt_add_string_list(char *, char *, void *);
void uwsgi_opt_add_dyn_dict(char *, char *, void *);
#ifdef UWSGI_PCRE
void uwsgi_opt_pcre_jit(char *, char *, void *);
void uwsgi_opt_add_regexp_dyn_dict(char *, char *, void *);
void uwsgi_opt_add_regexp_list(char *, char *, void *);
void uwsgi_opt_add_regexp_custom_list(char *, char *, void *);