unicorn 3.6.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.document +1 -0
  2. data/.manifest +13 -0
  3. data/ChangeLog +783 -1
  4. data/DESIGN +0 -8
  5. data/Documentation/GNUmakefile +1 -1
  6. data/GIT-VERSION-FILE +1 -1
  7. data/GIT-VERSION-GEN +1 -1
  8. data/GNUmakefile +2 -2
  9. data/HACKING +11 -0
  10. data/KNOWN_ISSUES +2 -2
  11. data/LATEST +24 -24
  12. data/Links +53 -0
  13. data/NEWS +66 -0
  14. data/PHILOSOPHY +49 -49
  15. data/Sandbox +13 -4
  16. data/TODO +0 -2
  17. data/TUNING +31 -9
  18. data/bin/unicorn +2 -1
  19. data/bin/unicorn_rails +2 -1
  20. data/examples/big_app_gc.rb +2 -33
  21. data/examples/nginx.conf +17 -4
  22. data/ext/unicorn_http/ext_help.h +16 -0
  23. data/ext/unicorn_http/extconf.rb +1 -0
  24. data/ext/unicorn_http/global_variables.h +9 -3
  25. data/ext/unicorn_http/unicorn_http.c +357 -259
  26. data/ext/unicorn_http/unicorn_http.rl +148 -50
  27. data/lib/unicorn/configurator.rb +36 -8
  28. data/lib/unicorn/const.rb +5 -3
  29. data/lib/unicorn/http_request.rb +1 -3
  30. data/lib/unicorn/http_server.rb +82 -95
  31. data/lib/unicorn/oob_gc.rb +61 -50
  32. data/lib/unicorn/socket_helper.rb +23 -8
  33. data/lib/unicorn/worker.rb +45 -4
  34. data/lib/unicorn.rb +8 -6
  35. data/script/isolate_for_tests +4 -2
  36. data/t/broken-app.ru +12 -0
  37. data/t/heartbeat-timeout.ru +12 -0
  38. data/t/oob_gc.ru +21 -0
  39. data/t/oob_gc_path.ru +21 -0
  40. data/t/t0001-reload-bad-config.sh +1 -0
  41. data/t/t0002-parser-error.sh +64 -1
  42. data/t/t0004-heartbeat-timeout.sh +69 -0
  43. data/t/t0009-broken-app.sh +56 -0
  44. data/t/t0019-max_header_len.sh +49 -0
  45. data/t/t0020-at_exit-handler.sh +49 -0
  46. data/t/t9001-oob_gc.sh +47 -0
  47. data/t/t9002-oob_gc-path.sh +75 -0
  48. data/test/benchmark/stack.ru +8 -0
  49. data/test/unit/test_droplet.rb +28 -0
  50. data/test/unit/test_http_parser.rb +60 -4
  51. data/test/unit/test_http_parser_ng.rb +54 -0
  52. data/test/unit/test_response.rb +1 -1
  53. data/test/unit/test_server.rb +1 -1
  54. data/test/unit/test_signals.rb +1 -1
  55. data/test/unit/test_socket_helper.rb +8 -0
  56. data/test/unit/test_upload.rb +1 -1
  57. data/unicorn.gemspec +3 -2
  58. metadata +44 -16
@@ -36,6 +36,22 @@ static void rb_18_str_set_len(VALUE str, long len)
36
36
  # endif
37
37
  #endif /* ! defined(OFFT2NUM) */
38
38
 
39
+ #if !defined(SIZET2NUM)
40
+ # if SIZEOF_SIZE_T == SIZEOF_LONG
41
+ # define SIZET2NUM(n) ULONG2NUM(n)
42
+ # else
43
+ # define SIZET2NUM(n) ULL2NUM(n)
44
+ # endif
45
+ #endif /* ! defined(SIZET2NUM) */
46
+
47
+ #if !defined(NUM2SIZET)
48
+ # if SIZEOF_SIZE_T == SIZEOF_LONG
49
+ # define NUM2SIZET(n) ((size_t)NUM2ULONG(n))
50
+ # else
51
+ # define NUM2SIZET(n) ((size_t)NUM2ULL(n))
52
+ # endif
53
+ #endif /* ! defined(NUM2SIZET) */
54
+
39
55
  #ifndef HAVE_RB_STR_MODIFY
40
56
  # define rb_str_modify(x) do {} while (0)
41
57
  #endif /* ! defined(HAVE_RB_STR_MODIFY) */
@@ -2,6 +2,7 @@
2
2
  require 'mkmf'
3
3
 
4
4
  have_macro("SIZEOF_OFF_T", "ruby.h") or check_sizeof("off_t", "sys/types.h")
5
+ have_macro("SIZEOF_SIZE_T", "ruby.h") or check_sizeof("size_t", "sys/types.h")
5
6
  have_macro("SIZEOF_LONG", "ruby.h") or check_sizeof("long", "sys/types.h")
6
7
  have_func("rb_str_set_len", "ruby.h")
7
8
  have_func("gmtime_r", "time.h")
@@ -1,6 +1,8 @@
1
1
  #ifndef global_variables_h
2
2
  #define global_variables_h
3
3
  static VALUE eHttpParserError;
4
+ static VALUE e413;
5
+ static VALUE e414;
4
6
 
5
7
  static VALUE g_rack_url_scheme;
6
8
  static VALUE g_request_method;
@@ -35,7 +37,7 @@ static VALUE g_http_11;
35
37
  static const char * const MAX_##N##_LENGTH_ERR = \
36
38
  "HTTP element " # N " is longer than the " # length " allowed length."
37
39
 
38
- NORETURN(static void parser_error(const char *));
40
+ NORETURN(static void parser_raise(VALUE klass, const char *));
39
41
 
40
42
  /**
41
43
  * Validates the max length of given input and throws an HttpParserError
@@ -43,7 +45,12 @@ NORETURN(static void parser_error(const char *));
43
45
  */
44
46
  #define VALIDATE_MAX_LENGTH(len, N) do { \
45
47
  if (len > MAX_##N##_LENGTH) \
46
- parser_error(MAX_##N##_LENGTH_ERR); \
48
+ parser_raise(eHttpParserError, MAX_##N##_LENGTH_ERR); \
49
+ } while (0)
50
+
51
+ #define VALIDATE_MAX_URI_LENGTH(len, N) do { \
52
+ if (len > MAX_##N##_LENGTH) \
53
+ parser_raise(e414, MAX_##N##_LENGTH_ERR); \
47
54
  } while (0)
48
55
 
49
56
  /** Defines global strings in the init method. */
@@ -59,7 +66,6 @@ DEF_MAX_LENGTH(REQUEST_URI, 1024 * 12);
59
66
  DEF_MAX_LENGTH(FRAGMENT, 1024); /* Don't know if this length is specified somewhere or not */
60
67
  DEF_MAX_LENGTH(REQUEST_PATH, 1024);
61
68
  DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10));
62
- DEF_MAX_LENGTH(HEADER, (1024 * (80 + 32)));
63
69
 
64
70
  static void init_globals(void)
65
71
  {