[PATCH 1/2] Introduce SERVICES_COUNT_MAX macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sync/service was using maximal number of services in ehter numberic form
(magic constant) or inconsistently, this means using
SERVICE_HANDLER_MAXIMUM_COUNT which means maximal number of handlers.

New macro solves this.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/ipc_glue.c            |    7 +++----
 exec/main.c                |    2 +-
 exec/service.c             |   14 +++++++-------
 exec/service.h             |    4 ++--
 exec/sync.c                |    7 ++++---
 include/corosync/coroapi.h |    2 ++
 6 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/exec/ipc_glue.c b/exec/ipc_glue.c
index a3f11c7..23123fa 100644
--- a/exec/ipc_glue.c
+++ b/exec/ipc_glue.c
@@ -82,7 +82,7 @@ struct outq_item {
 	struct list_head list;
 };
 
-static struct cs_ipcs_mapper ipcs_mapper[SERVICE_HANDLER_MAXIMUM_COUNT];
+static struct cs_ipcs_mapper ipcs_mapper[SERVICES_COUNT_MAX];
 
 static int32_t cs_ipcs_job_add(enum qb_loop_priority p,	void *data, qb_loop_job_dispatch_fn fn);
 static int32_t cs_ipcs_dispatch_add(enum qb_loop_priority p, int32_t fd, int32_t events,
@@ -691,7 +691,7 @@ static void cs_ipcs_check_for_flow_control(void)
 	int32_t i;
 	int32_t fc_enabled;
 
-	for (i = 0; i < SERVICE_HANDLER_MAXIMUM_COUNT; i++) {
+	for (i = 0; i < SERVICES_COUNT_MAX; i++) {
 		if (corosync_service[i] == NULL || ipcs_mapper[i].inst == NULL) {
 			continue;
 		}
@@ -751,7 +751,7 @@ void cs_ipcs_stats_update(void)
 	struct cs_ipcs_conn_context *cnx;
 	char key_name[ICMAP_KEYNAME_MAXLEN];
 
-	for (i = 0; i < SERVICE_HANDLER_MAXIMUM_COUNT; i++) {
+	for (i = 0; i < SERVICES_COUNT_MAX; i++) {
 		if (corosync_service[i] == NULL || ipcs_mapper[i].inst == NULL) {
 			continue;
 		}
@@ -797,7 +797,6 @@ void cs_ipcs_stats_update(void)
 
 			snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.overload", cnx->icmap_path);
 			icmap_set_uint64(key_name, cnx->overload);
-
 			qb_ipcs_connection_unref(c);
 		}
 	}
diff --git a/exec/main.c b/exec/main.c
index da89477..5bccb87 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -181,7 +181,7 @@ void corosync_state_dump (void)
 {
 	int i;
 
-	for (i = 0; i < SERVICE_HANDLER_MAXIMUM_COUNT; i++) {
+	for (i = 0; i < SERVICES_COUNT_MAX; i++) {
 		if (corosync_service[i] && corosync_service[i]->exec_dump_fn) {
 			corosync_service[i]->exec_dump_fn ();
 		}
diff --git a/exec/service.c b/exec/service.c
index effe4b2..f22a0af 100644
--- a/exec/service.c
+++ b/exec/service.c
@@ -107,12 +107,12 @@ struct seus_handler_data {
 	struct corosync_api_v1 *api;
 };
 
-struct corosync_service_engine *corosync_service[SERVICE_HANDLER_MAXIMUM_COUNT];
+struct corosync_service_engine *corosync_service[SERVICES_COUNT_MAX];
 
-const char *service_stats_rx[SERVICE_HANDLER_MAXIMUM_COUNT][64];
-const char *service_stats_tx[SERVICE_HANDLER_MAXIMUM_COUNT][64];
+const char *service_stats_rx[SERVICES_COUNT_MAX][SERVICE_HANDLER_MAXIMUM_COUNT];
+const char *service_stats_tx[SERVICES_COUNT_MAX][SERVICE_HANDLER_MAXIMUM_COUNT];
 
-int corosync_service_exiting[SERVICE_HANDLER_MAXIMUM_COUNT];
+int corosync_service_exiting[SERVICES_COUNT_MAX];
 
 static void (*service_unlink_all_complete) (void) = NULL;
 
@@ -182,7 +182,7 @@ char *corosync_service_link_and_init (
 static int service_priority_max(void)
 {
 	int lpc = 0, max = 0;
-	for(; lpc < SERVICE_HANDLER_MAXIMUM_COUNT; lpc++) {
+	for(; lpc < SERVICES_COUNT_MAX; lpc++) {
 		if(corosync_service[lpc] != NULL && corosync_service[lpc]->priority > max) {
 			max = corosync_service[lpc]->priority;
 		}
@@ -205,7 +205,7 @@ corosync_service_unlink_priority (
 
 	for(; *current_priority >= lowest_priority; *current_priority = *current_priority - 1) {
 		for(*current_service_engine = 0;
-			*current_service_engine < SERVICE_HANDLER_MAXIMUM_COUNT;
+			*current_service_engine < SERVICES_COUNT_MAX;
 			*current_service_engine = *current_service_engine + 1) {
 
 			if(corosync_service[*current_service_engine] == NULL ||
@@ -293,7 +293,7 @@ static unsigned int service_unlink_and_exit (
 	}
 	icmap_iter_finalize(iter);
 
-	if (service_found && service_id < SERVICE_HANDLER_MAXIMUM_COUNT
+	if (service_found && service_id < SERVICES_COUNT_MAX
 		&& corosync_service[service_id] != NULL) {
 
 		if (corosync_service[service_id]->exec_exit_fn) {
diff --git a/exec/service.h b/exec/service.h
index 647d0e0..1c41343 100644
--- a/exec/service.h
+++ b/exec/service.h
@@ -77,8 +77,8 @@ extern struct corosync_service_engine *corosync_service[];
 
 extern int corosync_service_exiting[];
 
-extern const char *service_stats_rx[SERVICE_HANDLER_MAXIMUM_COUNT][64];
-extern const char *service_stats_tx[SERVICE_HANDLER_MAXIMUM_COUNT][64];
+extern const char *service_stats_rx[SERVICES_COUNT_MAX][SERVICE_HANDLER_MAXIMUM_COUNT];
+extern const char *service_stats_tx[SERVICES_COUNT_MAX][SERVICE_HANDLER_MAXIMUM_COUNT];
 
 struct corosync_service_engine *votequorum_get_service_engine_ver0 (void);
 struct corosync_service_engine *vsf_quorum_get_service_engine_ver0 (void);
diff --git a/exec/sync.c b/exec/sync.c
index 2998988..f9f8cb4 100644
--- a/exec/sync.c
+++ b/exec/sync.c
@@ -58,6 +58,7 @@
 #include "schedwrk.h"
 #include "quorum.h"
 #include "sync.h"
+#include "main.h"
 
 LOGSYS_DECLARE_SUBSYS ("SYNC");
 
@@ -142,13 +143,13 @@ static size_t my_trans_list_entries = 0;
 
 static int my_processor_list_entries = 0;
 
-static struct service_entry my_service_list[128];
+static struct service_entry my_service_list[SERVICES_COUNT_MAX];
 
 static int my_service_list_entries = 0;
 
 static const struct memb_ring_id sync_ring_id;
 
-static struct service_entry my_initial_service_list[PROCESSOR_COUNT_MAX];
+static struct service_entry my_initial_service_list[SERVICES_COUNT_MAX];
 
 static int my_initial_service_list_entries;
 
@@ -201,7 +202,7 @@ int sync_init (
 	}
 
 	sync_synchronization_completed = synchronization_completed;
-	for (i = 0; i < 64; i++) {
+	for (i = 0; i < SERVICES_COUNT_MAX; i++) {
 		res = sync_callbacks_retrieve (i, &sync_callbacks);
 		if (res == -1) {
 			continue;
diff --git a/include/corosync/coroapi.h b/include/corosync/coroapi.h
index 77b5f8f..6069c0d 100644
--- a/include/corosync/coroapi.h
+++ b/include/corosync/coroapi.h
@@ -410,6 +410,8 @@ struct corosync_api_v1 {
 
 #define SERVICE_HANDLER_MAXIMUM_COUNT 64
 
+#define SERVICES_COUNT_MAX 64
+
 struct corosync_lib_handler {
 	void (*lib_handler_fn) (void *conn, const void *msg);
 	enum cs_lib_flow_control flow_control;
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux