From 55097bb572d9a6f9e5b3ed4ec9931d0977569718 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 15 Mar 2009 11:11:51 +0100 Subject: [PATCH] remove 'respond' from Request object in HTTPServer when connection is dead --- node.cc | 2 ++ node_http.cc | 10 ++++++++-- node_tcp.cc | 12 +++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/node.cc b/node.cc index 117d989..45e0ed8 100644 --- a/node.cc +++ b/node.cc @@ -100,6 +100,8 @@ void ReportException(v8::TryCatch* try_catch) { // print the exception. printf("%s\n", exception_string); } else { + message->PrintCurrentStackTrace(stdout); + // Print (filename):(line number): (message). v8::String::Utf8Value filename(message->GetScriptResourceName()); const char* filename_string = ToCString(filename); diff --git a/node_http.cc b/node_http.cc index 75648a5..f00c311 100644 --- a/node_http.cc +++ b/node_http.cc @@ -40,6 +40,8 @@ static Persistent put_str; static Persistent trace_str; static Persistent unlock_str; +#define INVALID_STATE_ERR 1 + class Server { public: Server (Handle _js_server); @@ -137,11 +139,12 @@ RespondCallback (const Arguments& args) { HandleScope scope; - // TODO check that args.Holder()->GetInternalField(0) - // is not NULL if so raise INVALID_STATE_ERR Handle v = args.Holder()->GetInternalField(0); if(v->IsUndefined()) { + // check that args.Holder()->GetInternalField(0) + // is not NULL if so raise INVALID_STATE_ERR printf("null request external\n"); + ThrowException(Integer::New(INVALID_STATE_ERR)); return Undefined(); } Handle field = Handle::Cast(v); @@ -317,6 +320,7 @@ HttpRequest::~HttpRequest () HandleScope scope; // needed? // delete a reference c++ HttpRequest js_object->SetInternalField(0, Undefined()); + js_object->Delete(respond_str); // dispose of Persistent handle so that // it can be GC'd normally. js_object.Dispose(); @@ -654,6 +658,8 @@ Init_http (Handle target) Local server_t = FunctionTemplate::New(newHTTPServer); server_t->InstanceTemplate()->SetInternalFieldCount(1); + + server_t->Set("INVALID_STATE_ERR", Integer::New(INVALID_STATE_ERR)); target->Set(String::New("HTTPServer"), server_t->GetFunction()); diff --git a/node_tcp.cc b/node_tcp.cc index 8db5d64..2f9b061 100644 --- a/node_tcp.cc +++ b/node_tcp.cc @@ -308,19 +308,13 @@ Init_tcp (Handle target) /* readyState constants */ readyState_CONNECTING = Persistent::New(Integer::New(READY_STATE_CONNECTING)); - client_t->InstanceTemplate()->Set ( String::NewSymbol("CONNECTING") - , readyState_CONNECTING - ); + client_t->Set ("CONNECTING", readyState_CONNECTING); readyState_OPEN = Persistent::New(Integer::New(READY_STATE_OPEN)); - client_t->InstanceTemplate()->Set ( String::NewSymbol("OPEN") - , readyState_OPEN - ); + client_t->Set ("OPEN", readyState_OPEN); readyState_CLOSED = Persistent::New(Integer::New(READY_STATE_CLOSED)); - client_t->InstanceTemplate()->Set ( String::NewSymbol("CLOSED") - , readyState_CLOSED - ); + client_t->Set ("CLOSED", readyState_CLOSED); /* write callback */ -- 2.7.4