diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2012-06-19 23:37:53 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2012-06-20 14:40:39 +0200 |
commit | fb4584b83ddfe645ac1b8c16385e9a4632171d96 (patch) | |
tree | 03f03573ddfe303f221be2cf9f9a6e6e202aac01 /daemons/cmirrord/local.c | |
parent | e77803edc95d9b40e367bc447ad316bb5f9d9d8a (diff) | |
download | lvm2-fb4584b83ddfe645ac1b8c16385e9a4632171d96.tar.gz lvm2-fb4584b83ddfe645ac1b8c16385e9a4632171d96.tar.xz lvm2-fb4584b83ddfe645ac1b8c16385e9a4632171d96.zip |
cmirrord: add test for closedir() and close()
Diffstat (limited to 'daemons/cmirrord/local.c')
-rw-r--r-- | daemons/cmirrord/local.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/daemons/cmirrord/local.c b/daemons/cmirrord/local.c index 8601cfd2..50711a1a 100644 --- a/daemons/cmirrord/local.c +++ b/daemons/cmirrord/local.c @@ -27,7 +27,7 @@ #define CN_VAL_DM_USERSPACE_LOG 0x1 #endif -static int cn_fd; /* Connector (netlink) socket fd */ +static int cn_fd = -1; /* Connector (netlink) socket fd */ static char recv_buf[2048]; static char send_buf[2048]; @@ -384,14 +384,18 @@ int init_local(void) r = bind(cn_fd, (struct sockaddr *) &addr, sizeof(addr)); if (r < 0) { - close(cn_fd); + if (close(cn_fd)) + LOG_ERROR("Failed to close socket: %s", + strerror(errno)); return EXIT_KERNEL_BIND; } opt = addr.nl_groups; r = setsockopt(cn_fd, 270, NETLINK_ADD_MEMBERSHIP, &opt, sizeof(opt)); if (r) { - close(cn_fd); + if (close(cn_fd)) + LOG_ERROR("Failed to close socket: %s", + strerror(errno)); return EXIT_KERNEL_SETSOCKOPT; } @@ -412,5 +416,7 @@ int init_local(void) void cleanup_local(void) { links_unregister(cn_fd); - close(cn_fd); + if (cn_fd >= 0 && close(cn_fd)) + LOG_ERROR("Failed to close socket: %s", + strerror(errno)); } |