Detect FreeBSD versions with broken MSG_CMSG_CLOEXEC

If we are compiling against a version of FreeBSD where MSG_CMSG_CLOEXEC
does not work, use the fallback directly. This was only fixed recently
(in https://cgit.freebsd.org/src/commit/?id=6ceacebdf52211).

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
This commit is contained in:
Alex Richardson 2021-03-19 10:02:41 +00:00 committed by Alexander Richardson
parent 42bf011f65
commit 382f368a27
3 changed files with 33 additions and 1 deletions

View file

@ -23,6 +23,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "../config.h"
#define _GNU_SOURCE
@ -341,7 +342,13 @@ do_os_wrappers_recvmsg_cloexec(int n)
struct marshal_data data;
data.nr_fds_begin = count_open_fds();
#if HAVE_BROKEN_MSG_CMSG_CLOEXEC
/* We call the fallback directly on FreeBSD versions with a broken
* MSG_CMSG_CLOEXEC, so we don't call the local recvmsg() wrapper. */
data.wrapped_calls = 0;
#else
data.wrapped_calls = n;
#endif
setup_marshal_data(&data);
data.nr_fds_conn = count_open_fds();