Skip to content
Permalink
Browse files
fix server socket end() method
  • Loading branch information
tve committed Dec 22, 2015
1 parent 6e34c5a commit 91e353d41f3d260716a39d27349dfc0c39fe06be
Showing 1 changed file with 8 additions and 3 deletions.
@@ -240,8 +240,12 @@ int socketSendData(JsNetwork *net, JsVar *connection, int sckt, JsVar **sendData
// we didn't send all of it... cut out what we did send
newSendData = jsvNewFromStringVar(*sendData, (size_t)num, JSVAPPENDSTRINGVAR_MAXLENGTH);
} else {
// we sent all of it! Issue a drain event
jsiQueueObjectCallbacks(connection, HTTP_NAME_ON_DRAIN, &connection, 1);
// we sent all of it! Issue a drain event, unless we want to close, then we shouldn't
// callback for more data
bool wantClose = jsvGetBoolAndUnLock(jsvObjectGetChild(connection,HTTP_NAME_CLOSE,0));
if (!wantClose) {
jsiQueueObjectCallbacks(connection, HTTP_NAME_ON_DRAIN, &connection, 1);
}
newSendData = jsvNewFromEmptyString();
}
jsvUnLock(*sendData);
@@ -368,7 +372,8 @@ bool socketServerConnectionsIdle(JsNetwork *net) {
jsvObjectSetChild(socket, HTTP_NAME_SEND_DATA, sendData); // socketSendData prob updated sendData
}
// only close if we want to close, have no data to send, and aren't receiving data
if (jsvGetBoolAndUnLock(jsvObjectGetChild(socket,HTTP_NAME_CLOSE,0)) && !sendData && num<=0)
bool wantClose = jsvGetBoolAndUnLock(jsvObjectGetChild(socket,HTTP_NAME_CLOSE,0));
if (wantClose && (!sendData || jsvIsEmptyString(sendData)) && num<=0)
closeConnectionNow = true;
else if (num > 0)
closeConnectionNow = false; // guarantee that anything received is processed

0 comments on commit 91e353d

Please sign in to comment.