summaryrefslogtreecommitdiff
path: root/ctdb/common/sock_io.c
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-01-30 14:30:51 +1100
committerMartin Schwenke <martins@samba.org>2017-02-17 10:44:14 +0100
commita0c22958c5078bde55775a45a3bab52ceffe3980 (patch)
treeeb20426486692b2d909e02bc12229f9ce149df45 /ctdb/common/sock_io.c
parent574914f8d45e9ec9f9c2c8a9c83e338c4394c85c (diff)
downloadsamba-a0c22958c5078bde55775a45a3bab52ceffe3980.tar.gz
ctdb-common: Refactor code to remove a stale socket
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/common/sock_io.c')
-rw-r--r--ctdb/common/sock_io.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ctdb/common/sock_io.c b/ctdb/common/sock_io.c
index 7431eec3250..3f7138f0b7f 100644
--- a/ctdb/common/sock_io.c
+++ b/ctdb/common/sock_io.c
@@ -31,6 +31,21 @@
#include "common/logging.h"
#include "common/sock_io.h"
+bool sock_clean(const char *sockpath)
+{
+ int ret;
+
+ ret = unlink(sockpath);
+ if (ret == 0) {
+ D_WARNING("Removed stale socket %s\n", sockpath);
+ } else if (errno != ENOENT) {
+ D_ERR("Failed to remove stale socket %s\n", sockpath);
+ return false;
+ }
+
+ return true;
+}
+
int sock_connect(const char *sockpath)
{
struct sockaddr_un addr;