[Sheepdog] [PATCH 4/6] collie: show boot error messages to the foreground
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Tue May 4 21:20:08 CEST 2010
For debugging, it is better to show error messages to the console
until collie starts working.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
collie/group.c | 10 +++++-----
collie/store.c | 8 ++++----
collie/work.c | 6 +++---
lib/event.c | 2 +-
lib/net.c | 12 ++++++------
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/collie/group.c b/collie/group.c
index 4bf1eeb..56caa33 100644
--- a/collie/group.c
+++ b/collie/group.c
@@ -1447,8 +1447,8 @@ int create_cluster(int port)
ret = cpg_initialize(&cpg_handle, &cb);
if (ret != CS_OK) {
- eprintf("Failed to initialize cpg, %d\n", ret);
- eprintf("Is corosync running?\n");
+ fprintf(stderr, "Failed to initialize cpg, %d\n", ret);
+ fprintf(stderr, "Is corosync running?\n");
return -1;
}
@@ -1462,17 +1462,17 @@ join_retry:
sleep(1);
goto join_retry;
case CS_ERR_SECURITY:
- eprintf("Permission error.\n");
+ fprintf(stderr, "Permission error.\n");
exit(1);
default:
- eprintf("Failed to join the sheepdog group, %d\n", ret);
+ fprintf(stderr, "Failed to join the sheepdog group, %d\n", ret);
exit(1);
break;
}
ret = cpg_local_get(cpg_handle, &nodeid);
if (ret != CS_OK) {
- eprintf("Failed to get the local node's identifier, %d\n", ret);
+ fprintf(stderr, "Failed to get the local node's identifier, %d\n", ret);
exit(1);
}
diff --git a/collie/store.c b/collie/store.c
index bf5824f..956d28a 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -1556,13 +1556,13 @@ again:
ret = stat(d, &s);
if (ret) {
if (retry || errno != ENOENT) {
- eprintf("can't handle the dir %s, %m\n", d);
+ fprintf(stderr, "can't handle the dir %s, %m\n", d);
return 1;
}
ret = mkdir(d, def_dmode);
if (ret) {
- eprintf("can't create the dir %s, %m\n", d);
+ fprintf(stderr, "can't create the dir %s, %m\n", d);
return 1;
} else {
*new = 1;
@@ -1572,7 +1572,7 @@ again:
}
if (!S_ISDIR(s.st_mode)) {
- eprintf("%s is not a directory\n", d);
+ fprintf(stderr, "%s is not a directory\n", d);
return 1;
}
@@ -1663,7 +1663,7 @@ static int init_epoch_path(char *base_path)
dir = opendir(path);
if (!dir) {
- vprintf(SDOG_ERR "failed to open the epoch dir, %m\n");
+ fprintf(stderr, "failed to open the epoch dir %s, %m\n", path);
return SD_RES_EIO;
}
diff --git a/collie/work.c b/collie/work.c
index bb67750..9a4d9fb 100644
--- a/collie/work.c
+++ b/collie/work.c
@@ -261,7 +261,7 @@ static int init_signalfd(void)
sig_fd = signalfd(-1, &mask, 0);
if (sig_fd < 0) {
- eprintf("failed to create a signal fd, %m\n");
+ fprintf(stderr, "failed to create a signal fd, %m\n");
return 1;
}
@@ -304,7 +304,7 @@ int init_work_queue(int nr)
worker_routine, wi);
if (ret) {
- eprintf("failed to create a worker thread, %d %s\n",
+ fprintf(stderr, "failed to create a worker thread, %d %s\n",
i, strerror(ret));
if (ret)
goto destroy_threads;
@@ -322,7 +322,7 @@ destroy_threads:
pthread_mutex_unlock(&wi->startup_lock);
for (; i > 0; i--) {
pthread_join(wi->worker_thread[i - 1], NULL);
- eprintf("stopped the worker thread %d\n", i - 1);
+ fprintf(stderr, "stopped the worker thread %d\n", i - 1);
}
/* destroy_cond_mutex: */
diff --git a/lib/event.c b/lib/event.c
index a24d3cb..5df1c77 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -78,7 +78,7 @@ int init_event(int nr)
{
efd = epoll_create(nr);
if (efd < 0) {
- eprintf("can't create epoll fd\n");
+ fprintf(stderr, "can't create epoll fd\n");
return -1;
}
return 0;
diff --git a/lib/net.c b/lib/net.c
index 12f6a37..53d8d19 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -107,7 +107,7 @@ int create_listen_ports(int port, int (*callback)(int fd, void *), void *data)
ret = getaddrinfo(NULL, servname, &hints, &res0);
if (ret) {
- eprintf("unable to get address info, %m\n");
+ fprintf(stderr, "unable to get address info, %m\n");
return 1;
}
@@ -120,7 +120,7 @@ int create_listen_ports(int port, int (*callback)(int fd, void *), void *data)
ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt,
sizeof(opt));
if (ret)
- eprintf("can't set SO_REUSEADDR, %m\n");
+ fprintf(stderr, "can't set SO_REUSEADDR, %m\n");
opt = 1;
if (res->ai_family == AF_INET6) {
@@ -141,20 +141,20 @@ int create_listen_ports(int port, int (*callback)(int fd, void *), void *data)
ret = listen(fd, SOMAXCONN);
if (ret) {
- eprintf("can't listen to server socket, %m\n");
+ fprintf(stderr, "can't listen to server socket, %m\n");
close(fd);
continue;
}
ret = fcntl(fd, F_GETFL);
if (ret < 0) {
- eprintf("can't fcntl (F_GETFL), %m\n");
+ fprintf(stderr, "can't fcntl (F_GETFL), %m\n");
close(fd);
continue;
} else {
ret = fcntl(fd, F_SETFL, ret | O_NONBLOCK);
if (ret < 0) {
- eprintf("can't fcntl (O_NONBLOCK), %m\n");
+ fprintf(stderr, "can't fcntl (O_NONBLOCK), %m\n");
close(fd);
continue;
}
@@ -172,7 +172,7 @@ int create_listen_ports(int port, int (*callback)(int fd, void *), void *data)
freeaddrinfo(res0);
if (!success)
- eprintf("can't create a listen fd\n");
+ fprintf(stderr, "can't create a listen fd\n");
return !success;
}
--
1.5.6.5
More information about the sheepdog
mailing list