diff options
author | Amitay Isaacs <amitay@gmail.com> | 2017-01-30 14:30:51 +1100 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2017-02-17 10:44:14 +0100 |
commit | a0c22958c5078bde55775a45a3bab52ceffe3980 (patch) | |
tree | eb20426486692b2d909e02bc12229f9ce149df45 /ctdb/common/sock_io.c | |
parent | 574914f8d45e9ec9f9c2c8a9c83e338c4394c85c (diff) | |
download | samba-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.c | 15 |
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; |