about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-26 06:23:28 +0000
committerEric Wong <normalperson@yhbt.net>2010-12-26 07:19:18 +0000
commit87b1cf4eef3d717d345d730f28ddaad319f2fb2f (patch)
treeb5fb29340a1d4123fa197fcf09e2db2033935fa4
parentc348223a045abb295b8c9d7dbf189264bc3a17c3 (diff)
downloadunicorn-87b1cf4eef3d717d345d730f28ddaad319f2fb2f.tar.gz
We need to preserve our internal flags and only clear them on
HttpParser#parse.  This allows the async concurrency models in
Rainbows! to work properly.
-rw-r--r--ext/unicorn_http/unicorn_http.rl7
-rw-r--r--test/unit/test_http_parser_ng.rb2
2 files changed, 5 insertions, 4 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index f9dc158..9b33e31 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -637,8 +637,8 @@ static VALUE HttpParser_parse(VALUE self)
   struct http_parser *hp = data_get(self);
   VALUE data = hp->buf;
 
-  if (hp->flags == UH_FL_TO_CLEAR) {
-    hp->flags = 0;
+  if (HP_FL_TEST(hp, TO_CLEAR)) {
+    http_parser_init(hp);
     rb_funcall(hp->env, id_clear, 0);
   }
 
@@ -736,8 +736,7 @@ static VALUE HttpParser_next(VALUE self)
   struct http_parser *hp = data_get(self);
 
   if ((HP_FL_ALL(hp, KEEPALIVE)) && (hp->nr_requests-- != 0)) {
-    http_parser_init(hp);
-    hp->flags = UH_FL_TO_CLEAR;
+    HP_FL_SET(hp, TO_CLEAR);
     return Qtrue;
   }
   return Qfalse;
diff --git a/test/unit/test_http_parser_ng.rb b/test/unit/test_http_parser_ng.rb
index 8bcb724..c5d2460 100644
--- a/test/unit/test_http_parser_ng.rb
+++ b/test/unit/test_http_parser_ng.rb
@@ -598,6 +598,8 @@ class HttpParserNgTest < Test::Unit::TestCase
     assert_equal req2, @parser.buf
     assert ! @parser.env.empty?
     assert @parser.next?
+    assert @parser.keepalive?
+    assert @parser.headers?
     assert_equal expect, @parser.env
     env2 = @parser.parse.dup
     host.replace "www.example.com"