Browse Source

fix mishandling of accept limit that caused a memory leak.

1.0.0
Georg Hopp 11 years ago
parent
commit
b148346924
  1. 16
      src/connector.c

16
src/connector.c

@ -59,7 +59,7 @@ connectorAccept(void * _this, TR_Event event)
TR_TcpSocket socket = TR_socketAccept( TR_TcpSocket socket = TR_socketAccept(
(TR_TcpSocket)connection->transport); (TR_TcpSocket)connection->transport);
while (socket && count++ < 100) {
while (socket) {
TR_socketNonblock((TR_Socket)socket); TR_socketNonblock((TR_Socket)socket);
TR_Connection new_con = TR_new( TR_Connection new_con = TR_new(
TR_Connection, TR_Connection,
@ -72,22 +72,10 @@ connectorAccept(void * _this, TR_Event event)
(TR_EventSubject)new_con, (TR_EventSubject)new_con,
TR_CON_EVENT_NEW_CON, TR_CON_EVENT_NEW_CON,
NULL)); NULL));
if (++count > 100) break;
socket = TR_socketAccept((TR_TcpSocket)connection->transport); socket = TR_socketAccept((TR_TcpSocket)connection->transport);
} }
/*
* reenable socket for poll
*/
TR_eventHandlerIssueEvent(
(TR_EventHandler)_this,
TR_eventSubjectEmit(
(TR_EventSubject)connection,
TR_CEP_EVENT_READ_BLOCK,
NULL));
/**
* TODO we need to identify socket failures and close socket then.
*/
return TR_EVENT_DONE; return TR_EVENT_DONE;
} }

Loading…
Cancel
Save