Răsfoiți Sursa

add request_shutdown call to coroapi.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2140 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 17 ani în urmă
părinte
comite
bc636acac7
4 a modificat fișierele cu 14 adăugiri și 31 ștergeri
  1. 2 1
      exec/apidef.c
  2. 8 30
      exec/main.c
  3. 2 0
      exec/main.h
  4. 2 0
      include/corosync/engine/coroapi.h

+ 2 - 1
exec/apidef.c

@@ -139,7 +139,8 @@ static struct corosync_api_v1 apidef_corosync_api_v1 = {
 	.plugin_interface_reference = lcr_ifact_reference,
 	.plugin_interface_reference = lcr_ifact_reference,
 	.plugin_interface_release = lcr_ifact_release,
 	.plugin_interface_release = lcr_ifact_release,
 	.error_memory_failure = _corosync_out_of_memory_error,
 	.error_memory_failure = _corosync_out_of_memory_error,
-	.fatal_error = _corosync_public_exit_error
+	.fatal_error = _corosync_public_exit_error,
+	.request_shutdown = corosync_request_shutdown
 };
 };
 
 
 void apidef_init (struct objdb_iface_ver0 *objdb) {
 void apidef_init (struct objdb_iface_ver0 *objdb) {

+ 8 - 30
exec/main.c

@@ -141,48 +141,31 @@ static void sigusr2_handler (int num)
 	}
 	}
 }
 }
 
 
-static void *corosync_exit (void *arg) __attribute__((__noreturn__));
-static void *corosync_exit (void *arg)
+/*
+ * TODO this function needs some love
+ */
+void corosync_request_shutdown (void)
 {
 {
 	if (api) {
 	if (api) {
 		corosync_service_unlink_all (api);
 		corosync_service_unlink_all (api);
 	}
 	}
 
 
-#ifdef DEBUG_MEMPOOL
-	int stats_inuse[MEMPOOL_GROUP_SIZE];
-	int stats_avail[MEMPOOL_GROUP_SIZE];
-	int stats_memoryused[MEMPOOL_GROUP_SIZE];
-	int i;
-
-	mempool_getstats (stats_inuse, stats_avail, stats_memoryused);
-	log_printf (LOGSYS_LEVEL_DEBUG, "Memory pools:\n");
-	for (i = 0; i < MEMPOOL_GROUP_SIZE; i++) {
-	log_printf (LOGSYS_LEVEL_DEBUG, "order %d size %d inuse %d avail %d memory used %d\n",
-		i, 1<<i, stats_inuse[i], stats_avail[i], stats_memoryused[i]);
-	}
-#endif
-
 	poll_stop (0);
 	poll_stop (0);
 	totempg_finalize ();
 	totempg_finalize ();
 	coroipcs_ipc_exit ();
 	coroipcs_ipc_exit ();
 	corosync_exit_error (AIS_DONE_EXIT);
 	corosync_exit_error (AIS_DONE_EXIT);
 }
 }
 
 
-pthread_t corosync_exit_thread;
-static void init_shutdown(void *data)
+static void sigquit_handler (int num)
 {
 {
-	pthread_create (&corosync_exit_thread, NULL, corosync_exit, NULL);
+	corosync_request_shutdown ();
 }
 }
 
 
-
-static poll_timer_handle shutdown_handle;
-static void sigquit_handler (int num)
+static void sigintr_handler (int num)
 {
 {
-	/* avoid creating threads from within the interrupt context */
-	poll_timer_add (corosync_poll_handle, 500, NULL, init_shutdown, &shutdown_handle);
+	corosync_request_shutdown ();
 }
 }
 
 
-
 static void sigsegv_handler (int num)
 static void sigsegv_handler (int num)
 {
 {
 	(void)signal (SIGSEGV, SIG_DFL);
 	(void)signal (SIGSEGV, SIG_DFL);
@@ -208,11 +191,6 @@ struct totempg_group corosync_group = {
 	.group_len	= 1
 	.group_len	= 1
 };
 };
 
 
-static void sigintr_handler (int signum)
-{
-	poll_timer_add (corosync_poll_handle, 500, NULL,
-			init_shutdown, &shutdown_handle);
-}
 
 
 
 
 static int pool_sizes[] = { 0, 0, 0, 0, 0, 4096, 0, 1, 0, /* 256 */
 static int pool_sizes[] = { 0, 0, 0, 0, 0, 4096, 0, 1, 0, /* 256 */

+ 2 - 0
exec/main.h

@@ -64,4 +64,6 @@ extern void message_source_set (mar_message_source_t *source, void *conn);
 
 
 extern int message_source_is_local (const mar_message_source_t *source);
 extern int message_source_is_local (const mar_message_source_t *source);
 
 
+extern void corosync_request_shutdown (void);
+
 #endif /* MAIN_H_DEFINED */
 #endif /* MAIN_H_DEFINED */

+ 2 - 0
include/corosync/engine/coroapi.h

@@ -573,6 +573,8 @@ struct corosync_api_v1 {
 	void (*error_memory_failure) (void);
 	void (*error_memory_failure) (void);
 #define corosync_fatal_error(err) api->fatal_error ((err), __FILE__, __LINE__)
 #define corosync_fatal_error(err) api->fatal_error ((err), __FILE__, __LINE__)
 	void (*fatal_error) (cs_fatal_error_t err, const char *file, unsigned int line);
 	void (*fatal_error) (cs_fatal_error_t err, const char *file, unsigned int line);
+
+	void (*request_shutdown) (void);
 };
 };
 
 
 #define SERVICE_ID_MAKE(a,b) ( ((a)<<16) | (b) )
 #define SERVICE_ID_MAKE(a,b) ( ((a)<<16) | (b) )