if nse's connect is issued on an open socket, close the old connection before

connecting - this should prevent starvation, in case a single script opens many
connections
This commit is contained in:
stoiko 2007-12-12 14:00:40 +00:00
parent 0012ee3dee
commit 24cca96f14

View file

@ -269,7 +269,18 @@ static int l_nsock_connect(lua_State* l) {
int error_id;
l_nsock_clear_buf(l, udata);
if(udata->nsiod!=NULL){
/*should a script try to connect a socket, which is already connected
* we close the old connection, since it would have no access to it
* anyways
*/
if(o.scriptTrace()){
log_write(LOG_STDOUT,"%s: Trying to connect already connected socket - closing!\n",SCRIPT_ENGINE);
}
l_nsock_close(l);
lua_pop(l,1);
}
error_id = getaddrinfo(addr, NULL, NULL, &dest);
if (error_id) {
error = gai_strerror(error_id);