[PATCH] IPC: allow for failures in the connection_created callback

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

 



Signed-off-by: Angus Salkeld <asalkeld@xxxxxxxxxx>
---
 exec/ipc_glue.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/exec/ipc_glue.c b/exec/ipc_glue.c
index 2a04495..f6b400a 100644
--- a/exec/ipc_glue.c
+++ b/exec/ipc_glue.c
@@ -303,12 +303,16 @@ static void cs_ipcs_connection_created(qb_ipcs_connection_t *c)
 	int set_client_pid = 0;
 	int set_proc_name = 0;
 
-	log_printf(LOG_DEBUG, "%s() new connection", __func__);
+	log_printf(LOG_DEBUG, "connection created");
 
 	service = qb_ipcs_service_id_get(c);
 
 	size += corosync_service[service]->private_data_size;
 	context = calloc(1, size);
+	if (context == NULL) {
+		qb_ipcs_disconnect(c);
+		return;
+	}
 
 	list_init(&context->outq_head);
 	context->queuing = QB_FALSE;
@@ -317,8 +321,11 @@ static void cs_ipcs_connection_created(qb_ipcs_connection_t *c)
 
 	qb_ipcs_context_set(c, context);
 
-	corosync_service[service]->lib_init_fn(c);
-
+	if (corosync_service[service]->lib_init_fn(c) != 0) {
+		log_printf(LOG_ERR, "lib_init_fn failed, disconnecting");
+		qb_ipcs_disconnect(c);
+		return;
+	}
 	icmap_inc("runtime.connections.active");
 
 	qb_ipcs_connection_stats_get(c, &stats, QB_FALSE);
@@ -341,7 +348,8 @@ static void cs_ipcs_connection_created(qb_ipcs_connection_t *c)
 
 	context->icmap_path = strdup(key_name);
 	if (context->icmap_path == NULL) {
-		return ;
+		qb_ipcs_disconnect(c);
+		return;
 	}
 
 	if (set_proc_name) {
-- 
1.7.7.6

_______________________________________________
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