Przeglądaj źródła

Add get/set context API calls to the cpg service.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1377 fd59a12c-fef9-0310-b244-a6a79926bd2f
Patrick Caulfield 18 lat temu
rodzic
commit
7c4ee5b91d
2 zmienionych plików z 51 dodań i 0 usunięć
  1. 12 0
      include/cpg.h
  2. 39 0
      lib/cpg.c

+ 12 - 0
include/cpg.h

@@ -142,6 +142,18 @@ cpg_error_t cpg_fd_get (
 	cpg_handle_t handle,
 	int *fd);
 
+/* 
+ * Get and set contexts for a CPG handle
+ */
+cpg_error_t cpg_context_get (
+	cpg_handle_t handle,
+	void **context);
+
+cpg_error_t cpg_context_set (
+	cpg_handle_t handle,
+	void *context);
+
+
 /*
  * Dispatch messages and configuration changes
  */

+ 39 - 0
lib/cpg.c

@@ -57,6 +57,7 @@ struct cpg_inst {
 	int finalize;
 	cpg_flow_control_state_t flow_control_state;
 	cpg_callbacks_t callbacks;
+	void *context;
 	pthread_mutex_t response_mutex;
 	pthread_mutex_t dispatch_mutex;
 };
@@ -190,6 +191,44 @@ cpg_error_t cpg_fd_get (
 	return (SA_AIS_OK);
 }
 
+cpg_error_t cpg_context_get (
+	cpg_handle_t handle,
+	void **context)
+{
+	SaAisErrorT error;
+	struct cpg_inst *cpg_inst;
+
+	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	if (error != SA_AIS_OK) {
+		return (error);
+	}
+
+	*context = cpg_inst->context;
+
+	saHandleInstancePut (&cpg_handle_t_db, handle);
+
+	return (SA_AIS_OK);
+}
+
+cpg_error_t cpg_context_set (
+	cpg_handle_t handle,
+	void *context)
+{
+	SaAisErrorT error;
+	struct cpg_inst *cpg_inst;
+
+	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	if (error != SA_AIS_OK) {
+		return (error);
+	}
+
+	cpg_inst->context = context;
+
+	saHandleInstancePut (&cpg_handle_t_db, handle);
+
+	return (SA_AIS_OK);
+}
+
 struct res_overlay {
 	mar_res_header_t header __attribute__((aligned(8)));
 	char data[512000];