From 140a032894512959c47b17482114fd30cb80f529 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 21 Apr 2009 23:36:01 +0200 Subject: [PATCH] oops. call onConnect callback not onRead callback after connecting --- src/net.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/net.cc b/src/net.cc index b718d9139b..b0fefcfca9 100644 --- a/src/net.cc +++ b/src/net.cc @@ -171,12 +171,14 @@ Socket::AfterResolve (eio_req *req) { Socket *socket = static_cast (req->data); struct addrinfo *address = static_cast(req->ptr2); + req->ptr2 = NULL; int r = 0; if (req->result == 0) { r = oi_socket_connect (&socket->socket_, address); } - freeaddrinfo(address); // this was allocated in the thread pool + if (address) + freeaddrinfo(address); // no error. return. if(r == 0 && req->result == 0) { @@ -185,7 +187,7 @@ Socket::AfterResolve (eio_req *req) } HandleScope scope; - Handle onconnect_value = socket->handle_->Get(ON_READ_SYMBOL); + Handle onconnect_value = socket->handle_->Get(ON_CONNECT_SYMBOL); if (!onconnect_value->IsFunction()) return 0; Handle onconnect = Handle::Cast(onconnect_value); @@ -408,6 +410,8 @@ Socket::OnTimeout (oi_socket *s) Socket *socket = static_cast (s->data); HandleScope scope; + printf("timeout\n"); + Handle ontimeout_value = socket->handle_->Get( String::NewSymbol("onTimeout") ); if (!ontimeout_value->IsFunction()) return; Handle ontimeout = Handle::Cast(ontimeout_value);