فهرست منبع

Warn user of missing dirs and exit gracefully.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2262 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 16 سال پیش
والد
کامیت
2d7937de26
4فایلهای تغییر یافته به همراه23 افزوده شده و 1 حذف شده
  1. 6 0
      exec/coroipcs.c
  2. 14 0
      exec/main.c
  3. 2 1
      exec/util.h
  4. 1 0
      test/cpgbench.c

+ 6 - 0
exec/coroipcs.c

@@ -795,6 +795,7 @@ extern void coroipcs_ipc_init (
 	int server_fd;
 	int server_fd;
 	struct sockaddr_un un_addr;
 	struct sockaddr_un un_addr;
 	int res;
 	int res;
+	struct stat stat_out;
 
 
 	api = init_state;
 	api = init_state;
 
 
@@ -826,6 +827,11 @@ extern void coroipcs_ipc_init (
 #if defined(COROSYNC_LINUX)
 #if defined(COROSYNC_LINUX)
 	sprintf (un_addr.sun_path + 1, "%s", api->socket_name);
 	sprintf (un_addr.sun_path + 1, "%s", api->socket_name);
 #else
 #else
+	res = stat (SOCKETDIR, &stat_out);
+	if (res == -1 || (res == 0 && !S_ISDIR(stat_out.st_mode))) {
+		api->log_printf ("Required directory not present %s\n", SOCKETDIR);
+		api->fatal_error ("Please create required directory.");
+	}
 	sprintf (un_addr.sun_path, "%s/%s", SOCKETDIR, api->socket_name);
 	sprintf (un_addr.sun_path, "%s/%s", SOCKETDIR, api->socket_name);
 	unlink (un_addr.sun_path);
 	unlink (un_addr.sun_path);
 #endif
 #endif

+ 14 - 0
exec/main.c

@@ -45,6 +45,7 @@
 #include <sys/un.h>
 #include <sys/un.h>
 #include <sys/time.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/resource.h>
+#include <sys/stat.h>
 #include <netinet/in.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <arpa/inet.h>
 #include <unistd.h>
 #include <unistd.h>
@@ -650,6 +651,8 @@ int main (int argc, char **argv)
 	char *iface;
 	char *iface;
 	int res, ch;
 	int res, ch;
 	int background, setprio;
 	int background, setprio;
+	struct stat stat_out;
+	char corosync_lib_dir[PATH_MAX];
 
 
 #if defined(HAVE_PTHREAD_SPIN_LOCK)
 #if defined(HAVE_PTHREAD_SPIN_LOCK)
 	pthread_spin_init (&serialize_spin, 0);
 	pthread_spin_init (&serialize_spin, 0);
@@ -811,6 +814,17 @@ int main (int argc, char **argv)
 		res = logsys_thread_priority_set (SCHED_OTHER, NULL, 1);
 		res = logsys_thread_priority_set (SCHED_OTHER, NULL, 1);
 	}
 	}
 
 
+	/*
+	 * Make sure required directory is present
+	 */
+	sprintf (corosync_lib_dir, "%s/lib/corosync", LOCALSTATEDIR);
+	res = stat (corosync_lib_dir, &stat_out);
+	if ((res == -1) || (res == 0 && !S_ISDIR(stat_out.st_mode))) {
+		log_printf (LOGSYS_LEVEL_ERROR, "Required directory not present %s.  Please create it.\n", corosync_lib_dir);
+		corosync_exit_error (AIS_DONE_DIR_NOT_PRESENT);
+	}
+	
+
 	res = totem_config_read (objdb, &totem_config, &error_string);
 	res = totem_config_read (objdb, &totem_config, &error_string);
 	if (res == -1) {
 	if (res == -1) {
 		log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
 		log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);

+ 2 - 1
exec/util.h

@@ -59,7 +59,8 @@ enum e_ais_done {
 	AIS_DONE_OBJDB = -13,
 	AIS_DONE_OBJDB = -13,
 	AIS_DONE_INIT_SERVICES = -14,
 	AIS_DONE_INIT_SERVICES = -14,
 	AIS_DONE_OUT_OF_MEMORY = -15,
 	AIS_DONE_OUT_OF_MEMORY = -15,
-	AIS_DONE_FATAL_ERR = -16
+	AIS_DONE_FATAL_ERR = -16,
+	AIS_DONE_DIR_NOT_PRESENT = -17
 };
 };
 
 
 /*
 /*

+ 1 - 0
test/cpgbench.c

@@ -177,6 +177,7 @@ int main (void) {
 
 
 	for (i = 0; i < 50; i++) { /* number of repetitions - up to 50k */
 	for (i = 0; i < 50; i++) { /* number of repetitions - up to 50k */
 		cpg_benchmark (handle, size);
 		cpg_benchmark (handle, size);
+		signal (SIGALRM, sigalrm_handler);
 		size += 1000;
 		size += 1000;
 	}
 	}