0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 07:31:03 +08:00

Merge pull request #4116 from zedalaye/remove_pair_socket_fd

Cleanup socket FD after pair is established. Fix #4086
This commit is contained in:
Luca Boccassi 2021-01-04 18:55:25 +00:00 committed by GitHub
commit 9936ce8bb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

14
RELICENSE/zedalaye.md Normal file
View File

@ -0,0 +1,14 @@
# Permission to Relicense under MPLv2
This is a statement by Pierre Yager
that grants permission to relicense its copyrights in the libzmq C++
library (ZeroMQ) under the Mozilla Public License v2 (MPLv2).
A portion of the commits made by the Github handle "zedalaye", with
commit author "Pierre Yager <pierre.y@gmail.com>" or
"Pierre Yager <pierre.yager@crisalid.com", are copyright of Pierre Yager.
This document hereby grants the libzmq project team to relicense libzmq,
including all past, present and future contributions of the author listed above.
Pierre Yager
2021/01/04

View File

@ -53,6 +53,9 @@
#endif
#include <direct.h>
#define rmdir _rmdir
#define unlink _unlink
#endif
#if defined ZMQ_HAVE_OPENVMS || defined ZMQ_HAVE_VXWORKS
@ -619,6 +622,16 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
rc = closesocket (listener);
wsa_assert (rc == 0);
// Cleanup temporary socket file descriptor
if (!filename.empty ()) {
rc = ::unlink (filename.c_str ());
if ((rc == 0) && !dirname.empty ()) {
rc = ::rmdir (dirname.c_str ());
dirname.clear ();
}
filename.clear ();
}
return 0;
error_closeclient:
@ -631,6 +644,17 @@ error_closelistener:
saved_errno = errno;
rc = closesocket (listener);
wsa_assert (rc == 0);
// Cleanup temporary socket file descriptor
if (!filename.empty ()) {
rc = ::unlink (filename.c_str ());
if ((rc == 0) && !dirname.empty ()) {
rc = ::rmdir (dirname.c_str ());
dirname.clear ();
}
filename.clear ();
}
errno = saved_errno;
return -1;