Browse Source

remove 'respond' from Request object in HTTPServer when connection is dead

v0.7.4-release
Ryan 16 years ago
parent
commit
55097bb572
  1. 2
      node.cc
  2. 10
      node_http.cc
  3. 12
      node_tcp.cc

2
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);

10
node_http.cc

@ -40,6 +40,8 @@ static Persistent<String> put_str;
static Persistent<String> trace_str;
static Persistent<String> unlock_str;
#define INVALID_STATE_ERR 1
class Server {
public:
Server (Handle<Object> _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<Value> 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<External> field = Handle<External>::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<Object> target)
Local<FunctionTemplate> 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());

12
node_tcp.cc

@ -308,19 +308,13 @@ Init_tcp (Handle<Object> target)
/* readyState constants */
readyState_CONNECTING = Persistent<Integer>::New(Integer::New(READY_STATE_CONNECTING));
client_t->InstanceTemplate()->Set ( String::NewSymbol("CONNECTING")
, readyState_CONNECTING
);
client_t->Set ("CONNECTING", readyState_CONNECTING);
readyState_OPEN = Persistent<Integer>::New(Integer::New(READY_STATE_OPEN));
client_t->InstanceTemplate()->Set ( String::NewSymbol("OPEN")
, readyState_OPEN
);
client_t->Set ("OPEN", readyState_OPEN);
readyState_CLOSED = Persistent<Integer>::New(Integer::New(READY_STATE_CLOSED));
client_t->InstanceTemplate()->Set ( String::NewSymbol("CLOSED")
, readyState_CLOSED
);
client_t->Set ("CLOSED", readyState_CLOSED);
/* write callback */

Loading…
Cancel
Save