瀏覽代碼

Finally fixed TCP sockets.

Adam Ierymenko 11 年之前
父節點
當前提交
d2c5d71502
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      node/SocketManager.cpp

+ 8 - 1
node/SocketManager.cpp

@@ -395,8 +395,13 @@ bool SocketManager::send(const InetAddress &to,bool tcp,const void *msg,unsigned
 		}
 		}
 
 
 		ts = SharedPtr<Socket>(new TcpSocket(this,s,connecting,to));
 		ts = SharedPtr<Socket>(new TcpSocket(this,s,connecting,to));
-		if (!ts->send(to,msg,msglen))
+		if (!ts->send(to,msg,msglen)) {
+			_fdSetLock.lock();
+			FD_CLR(s,&_readfds);
+			FD_CLR(s,&_writefds);
+			_fdSetLock.unlock();
 			return false;
 			return false;
+		}
 
 
 		{
 		{
 			Mutex::Lock _l(_tcpSockets_m);
 			Mutex::Lock _l(_tcpSockets_m);
@@ -408,6 +413,8 @@ bool SocketManager::send(const InetAddress &to,bool tcp,const void *msg,unsigned
 		if (connecting)
 		if (connecting)
 			FD_SET(s,&_writefds);
 			FD_SET(s,&_writefds);
 		_fdSetLock.unlock();
 		_fdSetLock.unlock();
+
+		_updateNfds();
 		whack();
 		whack();
 
 
 		return true;
 		return true;