1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Add log_sys_error for close

This commit is contained in:
Zdenek Kabelac 2012-02-28 10:14:06 +00:00
parent a46cc72fd2
commit 4d44893d60
2 changed files with 19 additions and 18 deletions

View File

@ -669,7 +669,8 @@ static int local_rendezvous_callback(struct local_client *thisfd, char *buf,
if (client_fd >= 0) {
newfd = malloc(sizeof(struct local_client));
if (!newfd) {
close(client_fd);
if (close(client_fd))
log_sys_error("close", "socket");
return 1;
}
@ -2113,7 +2114,7 @@ static int check_local_clvmd(void)
static void close_local_sock(int local_socket)
{
if (local_socket != -1 && close(local_socket))
stack;
log_sys_error("close", CLVMD_SOCKNAME);
if (CLVMD_SOCKNAME[0] != '\0' && unlink(CLVMD_SOCKNAME))
stack;

View File

@ -432,14 +432,12 @@ static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK);
if (fifos->client >= 0) {
/* server is running and listening */
close(fifos->client);
if (close(fifos->client))
log_sys_error("close", fifos->client_path);
return 1;
} else if (errno != ENXIO) {
/* problem */
log_error("%s: Can't open client fifo %s: %s",
__func__, fifos->client_path, strerror(errno));
log_sys_error("open", fifos->client_path);
return 0;
}
@ -447,14 +445,14 @@ static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
/* server is not running */
if (!strncmp(DMEVENTD_PATH, "/", 1) && stat(DMEVENTD_PATH, &statbuf)) {
log_error("Unable to find dmeventd.");
log_sys_error("stat", DMEVENTD_PATH);
return 0;
}
pid = fork();
if (pid < 0)
log_error("Unable to fork.");
log_sys_error("fork", "");
else if (!pid) {
execvp(args[0], args);
@ -484,23 +482,23 @@ int init_fifos(struct dm_event_fifos *fifos)
/* Open the fifo used to read from the daemon. */
if ((fifos->server = open(fifos->server_path, O_RDWR)) < 0) {
log_error("%s: open server fifo %s",
__func__, fifos->server_path);
log_sys_error("open", fifos->server_path);
return 0;
}
/* Lock out anyone else trying to do communication with the daemon. */
if (flock(fifos->server, LOCK_EX) < 0) {
log_error("%s: flock %s", __func__, fifos->server_path);
close(fifos->server);
log_sys_error("flock", fifos->server_path);
if (close(fifos->server))
log_sys_error("close", fifos->server_path);
return 0;
}
/* if ((fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK)) < 0) {*/
if ((fifos->client = open(fifos->client_path, O_RDWR | O_NONBLOCK)) < 0) {
log_error("%s: Can't open client fifo %s: %s",
__func__, fifos->client_path, strerror(errno));
close(fifos->server);
log_sys_error("open", fifos->client_path);
if (close(fifos->server))
log_sys_error("close", fifos->server_path);
return 0;
}
@ -528,8 +526,10 @@ void fini_fifos(struct dm_event_fifos *fifos)
if (flock(fifos->server, LOCK_UN))
log_error("flock unlock %s", fifos->server_path);
close(fifos->client);
close(fifos->server);
if (close(fifos->client))
log_sys_error("close", fifos->client_path);
if (close(fifos->server))
log_sys_error("close", fifos->server_path);
}
/* Get uuid of a device */