Changeset: ff4801e15f2e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ff4801e15f2e
Modified Files:
tools/merovingian/daemon/proxy.c
Branch: Jun2016
Log Message:
Avoid closing the same file descriptor twice.
In a multi-threaded application that is a race condition waiting to
happen.
Also see bug 4066.
diffs (20 lines):
diff --git a/tools/merovingian/daemon/proxy.c b/tools/merovingian/daemon/proxy.c
--- a/tools/merovingian/daemon/proxy.c
+++ b/tools/merovingian/daemon/proxy.c
@@ -182,9 +182,14 @@ startProxy(int psock, stream *cfdin, str
return(newErr("could not receive initial byte: %s",
strerror(errno)));
}
closesocket(ssock);
+ /* psock is the underlying socket of cfdin/cfout which we
+ * passed on to the client; we need to close the socket, but
+ * not call shutdown() on it, which would happen if we called
+ * close_stream(), so we call closesocket to close the socket
+ * and mnstr_destroy to free memory */
closesocket(psock);
- close_stream(cfdin);
- close_stream(cfout);
+ mnstr_destroy(cfdin);
+ mnstr_destroy(cfout);
return(NO_ERR);
} else {
hp = gethostbyname(conn);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list