Browse Source

oops. call onConnect callback not onRead callback after connecting

v0.7.4-release
Ryan 16 years ago
parent
commit
140a032894
  1. 8
      src/net.cc

8
src/net.cc

@ -171,12 +171,14 @@ Socket::AfterResolve (eio_req *req)
{ {
Socket *socket = static_cast<Socket*> (req->data); Socket *socket = static_cast<Socket*> (req->data);
struct addrinfo *address = static_cast<struct addrinfo *>(req->ptr2); struct addrinfo *address = static_cast<struct addrinfo *>(req->ptr2);
req->ptr2 = NULL;
int r = 0; int r = 0;
if (req->result == 0) { if (req->result == 0) {
r = oi_socket_connect (&socket->socket_, address); r = oi_socket_connect (&socket->socket_, address);
} }
freeaddrinfo(address); // this was allocated in the thread pool if (address)
freeaddrinfo(address);
// no error. return. // no error. return.
if(r == 0 && req->result == 0) { if(r == 0 && req->result == 0) {
@ -185,7 +187,7 @@ Socket::AfterResolve (eio_req *req)
} }
HandleScope scope; HandleScope scope;
Handle<Value> onconnect_value = socket->handle_->Get(ON_READ_SYMBOL); Handle<Value> onconnect_value = socket->handle_->Get(ON_CONNECT_SYMBOL);
if (!onconnect_value->IsFunction()) return 0; if (!onconnect_value->IsFunction()) return 0;
Handle<Function> onconnect = Handle<Function>::Cast(onconnect_value); Handle<Function> onconnect = Handle<Function>::Cast(onconnect_value);
@ -408,6 +410,8 @@ Socket::OnTimeout (oi_socket *s)
Socket *socket = static_cast<Socket*> (s->data); Socket *socket = static_cast<Socket*> (s->data);
HandleScope scope; HandleScope scope;
printf("timeout\n");
Handle<Value> ontimeout_value = socket->handle_->Get( String::NewSymbol("onTimeout") ); Handle<Value> ontimeout_value = socket->handle_->Get( String::NewSymbol("onTimeout") );
if (!ontimeout_value->IsFunction()) return; if (!ontimeout_value->IsFunction()) return;
Handle<Function> ontimeout = Handle<Function>::Cast(ontimeout_value); Handle<Function> ontimeout = Handle<Function>::Cast(ontimeout_value);

Loading…
Cancel
Save