Skip to content

Instantly share code, notes, and snippets.

View agentzh's full-sized avatar

Yichun Zhang agentzh

View GitHub Profile
@agentzh
agentzh / gist:2666809
Created May 12, 2012 14:28
error.log
2012/05/12 22:03:41 [debug] 4522#0: bind() 0.0.0.0:1984 #6
2012/05/12 22:03:41 [notice] 4522#0: using the "poll" event method
2012/05/12 22:03:41 [notice] 4522#0: nginx/1.0.15
2012/05/12 22:03:41 [notice] 4522#0: built by gcc 4.4.3 (GCC)
2012/05/12 22:03:41 [notice] 4522#0: OS: Linux 2.6.33.1
2012/05/12 22:03:41 [notice] 4522#0: sysctl(KERN_RTSIGMAX): 0
2012/05/12 22:03:41 [notice] 4522#0: getrlimit(RLIMIT_NOFILE): 119200:119200
2012/05/12 22:03:41 [debug] 4523#0: write: 7, 00007FFF65179D10, 5, 0
2012/05/12 22:03:41 [debug] 4523#0: malloc: 000000000072F3B0:32
2012/05/12 22:03:41 [debug] 4523#0: malloc: 0000000000710F50:24
@agentzh
agentzh / nginx.conf
Created May 12, 2012 14:58
nginx.conf
worker_processes 1;
daemon on;
master_process off;
error_log /home/agentz/git/lua-nginx-module/t/servroot/logs/error.log debug;
pid /home/agentz/git/lua-nginx-module/t/servroot/logs/nginx.pid;
env MOCKEAGAIN_VERBOSE;
env MOCKEAGAIN;
env MOCKEAGAIN_WRITE_TIMEOUT_PATTERN;
env LD_PRELOAD;
env DYLD_INSERT_LIBRARIES;
@agentzh
agentzh / Makefile
Created March 18, 2013 03:20
The Makefile used to process my Nginx modules' source code via the clang static analyzer.
c_files=$(wildcard src/ngx_*.c)
plist_vfiles=$(patsubst src/%.c,%.plist,$(c_files))
#all: ; echo $(clang_vfiles)
.PHONY: clang
clang: $(plist_vfiles)
%.plist: src/%.c
diff --git a/src/ngx_http_lua_regex.c b/src/ngx_http_lua_regex.c
index 41d0701..7772cbe 100644
--- a/src/ngx_http_lua_regex.c
+++ b/src/ngx_http_lua_regex.c
@@ -1097,6 +1097,10 @@ ngx_http_lua_ngx_re_parse_opts(lua_State *L, ngx_lua_regex_compile_t *re,
re->options |= PCRE_UTF8;
break;
+ case 'U':
+ re->options |= PCRE_UTF8|PCRE_NO_UTF8_CHECK;
@agentzh
agentzh / gist:5441274
Created April 23, 2013 06:32
feature: add "U" regex option to ngx_lua's ngx.re API (Version 2)
diff --git a/src/ngx_http_lua_regex.c b/src/ngx_http_lua_regex.c
index 63f0a1a..0ae60bc 100644
--- a/src/ngx_http_lua_regex.c
+++ b/src/ngx_http_lua_regex.c
@@ -38,6 +38,7 @@
#define NGX_LUA_RE_MODE_DFA (1<<1)
#define NGX_LUA_RE_MODE_JIT (1<<2)
#define NGX_LUA_RE_MODE_DUPNAMES (1<<3)
+#define NGX_LUA_RE_NO_UTF8_CHECK (1<<4)
@agentzh
agentzh / ngx-lua-req-header-user-agent.patch
Created April 24, 2013 00:23
bugfix: Modifying the User-Agent request header via ngx.req.set_header or ngx.req.clear_header did not update those special internal flags used in the Nginx internals, like "r->headers_in.msie6" and "r->headers_in.opera". Thanks Matthieu Tourne for the patch.
diff --git a/src/ngx_http_lua_headers_in.c b/src/ngx_http_lua_headers_in.c
index 9dd5a83..f4413b6 100644
--- a/src/ngx_http_lua_headers_in.c
+++ b/src/ngx_http_lua_headers_in.c
@@ -23,6 +23,8 @@ static ngx_int_t ngx_http_set_header_helper(ngx_http_request_t *r,
ngx_table_elt_t **output_header, unsigned no_create);
static ngx_int_t ngx_http_set_builtin_header(ngx_http_request_t *r,
ngx_http_lua_header_val_t *hv, ngx_str_t *value);
+static ngx_int_t ngx_http_set_user_agent_header(ngx_http_request_t *r,
+ ngx_http_lua_header_val_t *hv, ngx_str_t *value);
@agentzh
agentzh / ngx-lua-req-header-connection.patch
Created April 24, 2013 01:35
bugfix: modifying the Connection request header via ngx.req.set_header or ngx.req.clear_header did not update the special internal flags in the Nginx core, "r->headers_in.connection_type" and "r->headers_in.keep_alive_n". Thanks Matthieu Tourne for the patch.
diff --git a/src/ngx_http_lua_headers_in.c b/src/ngx_http_lua_headers_in.c
index f4413b6..bd4af76 100644
--- a/src/ngx_http_lua_headers_in.c
+++ b/src/ngx_http_lua_headers_in.c
@@ -25,6 +25,8 @@ static ngx_int_t ngx_http_set_builtin_header(ngx_http_request_t *r,
ngx_http_lua_header_val_t *hv, ngx_str_t *value);
static ngx_int_t ngx_http_set_user_agent_header(ngx_http_request_t *r,
ngx_http_lua_header_val_t *hv, ngx_str_t *value);
+static ngx_int_t ngx_http_set_connection_header(ngx_http_request_t *r,
+ ngx_http_lua_header_val_t *hv, ngx_str_t *value);
@agentzh
agentzh / ngx-lua-set-cookie-header.patch
Created April 24, 2013 19:48
bugfix: modifying the Cookie request headers via ngx.req.set_header or ngx.req.clear_header did not update the Nginx internal data structure, r->headers_in.cookies, at the same time, which might cause issues when reading variables $cookie_COOKIE, for example. thanks Matthieu Tourne for the patch.
@agentzh
agentzh / gist:5455071
Created April 24, 2013 19:57
Matthieu's original patch for built-in-header-set
diff --git a/src/ngx_http_lua_headers_in.c b/src/ngx_http_lua_headers_in.c
index 9dd5a83..425005c 100644
--- a/src/ngx_http_lua_headers_in.c
+++ b/src/ngx_http_lua_headers_in.c
@@ -23,6 +23,12 @@ static ngx_int_t ngx_http_set_header_helper(ngx_http_request_t *r,
ngx_table_elt_t **output_header, unsigned no_create);
static ngx_int_t ngx_http_set_builtin_header(ngx_http_request_t *r,
ngx_http_lua_header_val_t *hv, ngx_str_t *value);
+static ngx_int_t ngx_http_set_connection(ngx_http_request_t *r,
+ ngx_http_lua_header_val_t *hv, ngx_str_t *value);
@agentzh
agentzh / gist:5828023
Last active December 18, 2015 18:49
Kernel panic when using ubacktrace/print_ubacktrace in timer.profile with systemtap 2.3.x in kernel 3.9.4.
[112186.086052] INFO: rcu_sched self-detected stall on CPU { 10} (t=6000 jiffies g=1519966 c=1519965 q=3)
[112186.096687] Pid: 47, comm: migration/10 Tainted: G O 3.9.4 #1
[112186.105319] Call Trace:
[112186.106073] INFO: rcu_sched detected stalls on CPUs/tasks: { 10 11} (detected by 9, t=6002 jiffies, g=1519966, c=1519965, q=3)
[112186.106074] Task dump for CPU 10:
[112186.106077] migration/10 R running task 0 47 2 0x00000000
[112186.106080] 0000000000000000 ffffffff814f5c4a 0000000000013c40 ffff880c240bbfd8
[112186.106082] 000000002767820c ffff880c2403b080 ffffffff81a39ba0 ffff880c240b1c50
[112186.106084] ffff880c240b1c50 ffff880c240b1c50 0000000000000000 ffffffff8105a96f
[112186.106085] Call Trace: