Skip to content

Instantly share code, notes, and snippets.

@ry
Created December 24, 2011 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ry/e52c76f86e5cbd83afd4 to your computer and use it in GitHub Desktop.
Save ry/e52c76f86e5cbd83afd4 to your computer and use it in GitHub Desktop.
From 18d15c783d6ec419905caa301b9f84839b16d0f3 Mon Sep 17 00:00:00 2001
From: Ryan Dahl <ry@tinyclouds.org>
Date: Fri, 23 Dec 2011 15:38:24 -0800
Subject: [PATCH] Move HandleScopes around in http-parser binding
---
src/node_http_parser.cc | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc
index 32fd08d..1e533d5 100644
--- a/src/node_http_parser.cc
+++ b/src/node_http_parser.cc
@@ -120,20 +120,18 @@ static size_t current_buffer_len;
#define HTTP_CB(name) \
static int name(http_parser* p_) { \
- HandleScope scope; \
Parser* self = container_of(p_, Parser, parser_); \
return self->name##_(); \
} \
- int always_inline name##_()
+ int name##_()
#define HTTP_DATA_CB(name) \
static int name(http_parser* p_, const char* at, size_t length) { \
- HandleScope scope; \
Parser* self = container_of(p_, Parser, parser_); \
return self->name##_(at, length); \
} \
- int always_inline name##_(const char* at, size_t length)
+ int name##_(const char* at, size_t length)
static inline Persistent<String>
@@ -248,12 +246,15 @@ public:
HTTP_DATA_CB(on_url) {
+ HandleScope scope;
url_.Update(at, length);
return 0;
}
HTTP_DATA_CB(on_header_field) {
+ HandleScope scope;
+
if (num_fields_ == num_values_) {
// start of new field name
if (++num_fields_ == ARRAY_SIZE(fields_)) {
@@ -274,6 +275,8 @@ public:
HTTP_DATA_CB(on_header_value) {
+ HandleScope scope;
+
if (num_values_ != num_fields_) {
// start of new header value
values_[++num_values_].Reset();
@@ -289,6 +292,8 @@ public:
HTTP_CB(on_headers_complete) {
+ HandleScope scope;
+
Local<Value> cb = handle_->Get(on_headers_complete_sym);
if (!cb->IsFunction())
@@ -557,6 +562,7 @@ private:
void Init(enum http_parser_type type) {
+ HandleScope scope;
http_parser_init(&parser_, type);
url_.Reset();
num_fields_ = -1;
--
1.7.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment