unicorn 5.3.1 → 5.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.manifest +2 -0
- data/.olddoc.yml +1 -1
- data/Application_Timeouts +4 -4
- data/Documentation/unicorn.1.txt +1 -1
- data/Documentation/unicorn_rails.1.txt +6 -8
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +6 -1
- data/ISSUES +10 -10
- data/LATEST +22 -102
- data/LICENSE +2 -2
- data/Links +9 -7
- data/NEWS +107 -0
- data/README +13 -6
- data/Sandbox +2 -2
- data/bin/unicorn +3 -1
- data/bin/unicorn_rails +2 -2
- data/examples/logrotate.conf +1 -1
- data/examples/nginx.conf +3 -2
- data/ext/unicorn_http/common_field_optimization.h +24 -6
- data/ext/unicorn_http/extconf.rb +30 -0
- data/ext/unicorn_http/global_variables.h +2 -2
- data/ext/unicorn_http/httpdate.c +2 -2
- data/ext/unicorn_http/unicorn_http.c +229 -219
- data/ext/unicorn_http/unicorn_http.rl +19 -9
- data/lib/unicorn/configurator.rb +13 -2
- data/lib/unicorn/http_request.rb +2 -2
- data/lib/unicorn/http_response.rb +3 -2
- data/lib/unicorn/http_server.rb +21 -23
- data/lib/unicorn/launcher.rb +1 -1
- data/lib/unicorn/socket_helper.rb +4 -3
- data/lib/unicorn/util.rb +3 -3
- data/lib/unicorn/version.rb +1 -1
- data/lib/unicorn/worker.rb +16 -2
- data/lib/unicorn.rb +26 -9
- data/man/man1/unicorn.1 +7 -5
- data/man/man1/unicorn_rails.1 +11 -11
- data/t/README +4 -4
- data/t/hijack.ru +12 -0
- data/t/t0200-rack-hijack.sh +22 -1
- data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
- data/t/t0301.ru +13 -0
- data/test/exec/test_exec.rb +6 -7
- data/test/unit/test_ccc.rb +1 -1
- data/test/unit/test_droplet.rb +1 -1
- data/test/unit/test_http_parser.rb +16 -0
- data/test/unit/test_request.rb +10 -10
- data/test/unit/test_server.rb +5 -5
- data/test/unit/test_signals.rb +2 -2
- data/test/unit/test_socket_helper.rb +4 -4
- data/test/unit/test_util.rb +25 -0
- data/unicorn.gemspec +1 -1
- metadata +5 -4
@@ -58,26 +58,44 @@ static struct common_field common_http_fields[] = {
|
|
58
58
|
|
59
59
|
#define HTTP_PREFIX "HTTP_"
|
60
60
|
#define HTTP_PREFIX_LEN (sizeof(HTTP_PREFIX) - 1)
|
61
|
+
static ID id_uminus;
|
62
|
+
|
63
|
+
/* this dedupes under Ruby 2.5+ (December 2017) */
|
64
|
+
static VALUE str_dd_freeze(VALUE str)
|
65
|
+
{
|
66
|
+
if (STR_UMINUS_DEDUPE)
|
67
|
+
return rb_funcall(str, id_uminus, 0);
|
68
|
+
|
69
|
+
/* freeze,since it speeds up older MRI slightly */
|
70
|
+
OBJ_FREEZE(str);
|
71
|
+
return str;
|
72
|
+
}
|
73
|
+
|
74
|
+
static VALUE str_new_dd_freeze(const char *ptr, long len)
|
75
|
+
{
|
76
|
+
return str_dd_freeze(rb_str_new(ptr, len));
|
77
|
+
}
|
61
78
|
|
62
79
|
/* this function is not performance-critical, called only at load time */
|
63
|
-
static void init_common_fields(
|
80
|
+
static void init_common_fields(void)
|
64
81
|
{
|
65
82
|
int i;
|
66
83
|
struct common_field *cf = common_http_fields;
|
67
84
|
char tmp[64];
|
85
|
+
|
86
|
+
id_uminus = rb_intern("-@");
|
68
87
|
memcpy(tmp, HTTP_PREFIX, HTTP_PREFIX_LEN);
|
69
88
|
|
70
89
|
for(i = ARRAY_SIZE(common_http_fields); --i >= 0; cf++) {
|
71
90
|
/* Rack doesn't like certain headers prefixed with "HTTP_" */
|
72
91
|
if (!strcmp("CONTENT_LENGTH", cf->name) ||
|
73
92
|
!strcmp("CONTENT_TYPE", cf->name)) {
|
74
|
-
cf->value =
|
93
|
+
cf->value = str_new_dd_freeze(cf->name, cf->len);
|
75
94
|
} else {
|
76
95
|
memcpy(tmp + HTTP_PREFIX_LEN, cf->name, cf->len + 1);
|
77
|
-
cf->value =
|
96
|
+
cf->value = str_new_dd_freeze(tmp, HTTP_PREFIX_LEN + cf->len);
|
78
97
|
}
|
79
|
-
|
80
|
-
rb_ary_push(mark_ary, cf->value);
|
98
|
+
rb_gc_register_mark_object(cf->value);
|
81
99
|
}
|
82
100
|
}
|
83
101
|
|
@@ -105,7 +123,7 @@ static VALUE uncommon_field(const char *field, size_t flen)
|
|
105
123
|
memcpy(RSTRING_PTR(f) + HTTP_PREFIX_LEN, field, flen);
|
106
124
|
assert(*(RSTRING_PTR(f) + RSTRING_LEN(f)) == '\0' &&
|
107
125
|
"string didn't end with \\0"); /* paranoia */
|
108
|
-
return
|
126
|
+
return HASH_ASET_DEDUPE ? f : str_dd_freeze(f);
|
109
127
|
}
|
110
128
|
|
111
129
|
#endif /* common_field_optimization_h */
|
data/ext/unicorn_http/extconf.rb
CHANGED
@@ -8,4 +8,34 @@ have_func("rb_str_set_len", "ruby.h") or abort 'Ruby 1.9.3+ required'
|
|
8
8
|
have_func("rb_hash_clear", "ruby.h") # Ruby 2.0+
|
9
9
|
have_func("gmtime_r", "time.h")
|
10
10
|
|
11
|
+
message('checking if String#-@ (str_uminus) dedupes... ')
|
12
|
+
begin
|
13
|
+
a = -(%w(t e s t).join)
|
14
|
+
b = -(%w(t e s t).join)
|
15
|
+
if a.equal?(b)
|
16
|
+
$CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=1 '
|
17
|
+
message("yes\n")
|
18
|
+
else
|
19
|
+
$CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=0 '
|
20
|
+
message("no, needs Ruby 2.5+\n")
|
21
|
+
end
|
22
|
+
rescue NoMethodError
|
23
|
+
$CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=0 '
|
24
|
+
message("no, String#-@ not available\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
message('checking if Hash#[]= (rb_hash_aset) dedupes... ')
|
28
|
+
h = {}
|
29
|
+
x = {}
|
30
|
+
r = rand.to_s
|
31
|
+
h[%W(#{r}).join('')] = :foo
|
32
|
+
x[%W(#{r}).join('')] = :foo
|
33
|
+
if x.keys[0].equal?(h.keys[0])
|
34
|
+
$CPPFLAGS += ' -DHASH_ASET_DEDUPE=1 '
|
35
|
+
message("yes\n")
|
36
|
+
else
|
37
|
+
$CPPFLAGS += ' -DHASH_ASET_DEDUPE=0 '
|
38
|
+
message("no, needs Ruby 2.6+\n")
|
39
|
+
end
|
40
|
+
|
11
41
|
create_makefile("unicorn_http")
|
@@ -56,7 +56,7 @@ NORETURN(static void parser_raise(VALUE klass, const char *));
|
|
56
56
|
/** Defines global strings in the init method. */
|
57
57
|
#define DEF_GLOBAL(N, val) do { \
|
58
58
|
g_##N = rb_obj_freeze(rb_str_new(val, sizeof(val) - 1)); \
|
59
|
-
|
59
|
+
rb_gc_register_mark_object(g_##N); \
|
60
60
|
} while (0)
|
61
61
|
|
62
62
|
/* Defines the maximum allowed lengths for various input elements.*/
|
@@ -67,7 +67,7 @@ DEF_MAX_LENGTH(FRAGMENT, 1024); /* Don't know if this length is specified somewh
|
|
67
67
|
DEF_MAX_LENGTH(REQUEST_PATH, 4096); /* common PATH_MAX on modern systems */
|
68
68
|
DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10));
|
69
69
|
|
70
|
-
static void init_globals(
|
70
|
+
static void init_globals(void)
|
71
71
|
{
|
72
72
|
DEF_GLOBAL(rack_url_scheme, "rack.url_scheme");
|
73
73
|
DEF_GLOBAL(request_method, "REQUEST_METHOD");
|
data/ext/unicorn_http/httpdate.c
CHANGED
@@ -64,13 +64,13 @@ static VALUE httpdate(VALUE self)
|
|
64
64
|
return buf;
|
65
65
|
}
|
66
66
|
|
67
|
-
void init_unicorn_httpdate(
|
67
|
+
void init_unicorn_httpdate(void)
|
68
68
|
{
|
69
69
|
VALUE mod = rb_define_module("Unicorn");
|
70
70
|
mod = rb_define_module_under(mod, "HttpResponse");
|
71
71
|
|
72
72
|
buf = rb_str_new(0, buf_capa - 1);
|
73
|
-
|
73
|
+
rb_gc_register_mark_object(buf);
|
74
74
|
buf_ptr = RSTRING_PTR(buf);
|
75
75
|
httpdate(Qnil);
|
76
76
|
|