* Copyright (C) 2011 EfficiOS Inc.
* Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
- * SPDX-License-Identifier: GPL-2.0-only
+ * SPDX-License-Identifier: LGPL-2.1-only
*
*/
#include <sys/types.h>
#include <unistd.h>
-#include <common/common.h>
-#include <common/compat/errno.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/fd-handle.h>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/fd-handle.hpp>
-#include "unix.h"
+#include "unix.hpp"
/*
* Connect to unix socket using the path name.
/*
* We consider EPIPE and EAGAIN/EWOULDBLOCK as expected.
*/
+ DIAGNOSTIC_PUSH
+ DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EPIPE) {
+ DIAGNOSTIC_POP
/*
* Nothing was recv.
*/
/*
* We consider EPIPE and EAGAIN/EWOULDBLOCK as expected.
*/
+ DIAGNOSTIC_PUSH
+ DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EPIPE) {
+ DIAGNOSTIC_POP
/*
* This can happen in non blocking mode.
* Nothing was sent.
/* Shutdown receptions and transmissions */
ret = shutdown(sock, SHUT_RDWR);
if (ret < 0) {
- PERROR("shutdown");
+ /*
+ * The socket is already disconnected, don't error out.
+ * This doesn't happen on Linux, but it does on FreeBSD, see:
+ * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227259
+ */
+ if (errno == ENOTCONN) {
+ ret = 0;
+ } else {
+ PERROR("shutdown");
+ }
}
closeret = close(sock);
/*
* We consider EPIPE and EAGAIN/EWOULDBLOCK as expected.
*/
+ DIAGNOSTIC_PUSH
+ DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ DIAGNOSTIC_POP
/*
* This can happen in non blocking mode.
* Nothing was sent.
/*
* We consider EPIPE and EAGAIN/EWOULDBLOCK as expected.
*/
+ DIAGNOSTIC_PUSH
+ DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ DIAGNOSTIC_POP
/*
* This can happen in non blocking mode.
* Nothing was recv.
return ret;
}
#elif (defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__))
-int lttcomm_setsockopt_creds_unix_sock(int sock)
+int lttcomm_setsockopt_creds_unix_sock(int sock __attribute__((unused)))
{
return 0;
}