ソースを参照

Rewrite of CPG. It solves problems with double delete.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2124 fd59a12c-fef9-0310-b244-a6a79926bd2f
Jan Friesse 17 年 前
コミット
058f50314c
5 ファイル変更380 行追加525 行削除
  1. 1 0
      include/corosync/corotypes.h
  2. 5 8
      include/corosync/ipc_cpg.h
  3. 9 0
      include/corosync/mar_cpg.h
  4. 29 41
      lib/cpg.c
  5. 336 476
      services/cpg.c

+ 1 - 0
include/corosync/corotypes.h

@@ -135,6 +135,7 @@ typedef enum {
 #define CPG_ERR_NO_MEMORY			CS_ERR_NO_MEMORY
 #define CPG_ERR_NO_MEMORY			CS_ERR_NO_MEMORY
 #define CPG_ERR_BAD_HANDLE			CS_ERR_BAD_HANDLE
 #define CPG_ERR_BAD_HANDLE			CS_ERR_BAD_HANDLE
 #define CPG_ERR_ACCESS				CS_ERR_ACCESS
 #define CPG_ERR_ACCESS				CS_ERR_ACCESS
+#define CPG_ERR_BUSY				CS_ERR_BUSY
 #define CPG_ERR_NOT_EXIST			CS_ERR_NOT_EXIST
 #define CPG_ERR_NOT_EXIST			CS_ERR_NOT_EXIST
 #define CPG_ERR_EXIST				CS_ERR_EXIST
 #define CPG_ERR_EXIST				CS_ERR_EXIST
 #define CPG_ERR_NOT_SUPPORTED		CS_ERR_NOT_SUPPORTED
 #define CPG_ERR_NOT_SUPPORTED		CS_ERR_NOT_SUPPORTED

+ 5 - 8
include/corosync/ipc_cpg.h

@@ -4,6 +4,7 @@
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Author: Christine Caulfield (ccaulfie@redhat.com)
  * Author: Christine Caulfield (ccaulfie@redhat.com)
+ * Author: Jan Friesse (jfriesse@redhat.com)
  *
  *
  * This software licensed under BSD license, the text of which follows:
  * This software licensed under BSD license, the text of which follows:
  *
  *
@@ -42,9 +43,7 @@ enum req_cpg_types {
 	MESSAGE_REQ_CPG_LEAVE = 1,
 	MESSAGE_REQ_CPG_LEAVE = 1,
 	MESSAGE_REQ_CPG_MCAST = 2,
 	MESSAGE_REQ_CPG_MCAST = 2,
 	MESSAGE_REQ_CPG_MEMBERSHIP = 3,
 	MESSAGE_REQ_CPG_MEMBERSHIP = 3,
-	MESSAGE_REQ_CPG_TRACKSTART = 4,
-	MESSAGE_REQ_CPG_TRACKSTOP = 5,
-	MESSAGE_REQ_CPG_LOCAL_GET = 6
+	MESSAGE_REQ_CPG_LOCAL_GET = 4,
 };
 };
 
 
 enum res_cpg_types {
 enum res_cpg_types {
@@ -54,11 +53,9 @@ enum res_cpg_types {
 	MESSAGE_RES_CPG_MEMBERSHIP = 3,
 	MESSAGE_RES_CPG_MEMBERSHIP = 3,
 	MESSAGE_RES_CPG_CONFCHG_CALLBACK = 4,
 	MESSAGE_RES_CPG_CONFCHG_CALLBACK = 4,
 	MESSAGE_RES_CPG_DELIVER_CALLBACK = 5,
 	MESSAGE_RES_CPG_DELIVER_CALLBACK = 5,
-	MESSAGE_RES_CPG_TRACKSTART = 6,
-	MESSAGE_RES_CPG_TRACKSTOP = 7,
-	MESSAGE_RES_CPG_FLOW_CONTROL_STATE_SET = 8,
-	MESSAGE_RES_CPG_LOCAL_GET = 9,
-	MESSAGE_RES_CPG_FLOWCONTROL_CALLBACK = 10
+	MESSAGE_RES_CPG_FLOW_CONTROL_STATE_SET = 6,
+	MESSAGE_RES_CPG_LOCAL_GET = 7,
+	MESSAGE_RES_CPG_FLOWCONTROL_CALLBACK = 8
 };
 };
 
 
 enum lib_cpg_confchg_reason {
 enum lib_cpg_confchg_reason {

+ 9 - 0
include/corosync/mar_cpg.h

@@ -86,4 +86,13 @@ static inline void marshall_to_mar_cpg_address_t (
 	dest->reason = src->reason;
 	dest->reason = src->reason;
 }
 }
 
 
+static inline int mar_name_compare (
+		const mar_cpg_name_t *g1,
+		const mar_cpg_name_t *g2)
+{
+	return (g1->length == g2->length?
+		memcmp (g1->value, g2->value, g1->length):
+		g1->length - g2->length);
+}
+
 #endif /* MAR_CPG_H_DEFINED */
 #endif /* MAR_CPG_H_DEFINED */

+ 29 - 41
lib/cpg.c

@@ -391,33 +391,12 @@ cs_error_t cpg_join (
 	struct iovec iov[2];
 	struct iovec iov[2];
 	struct req_lib_cpg_join req_lib_cpg_join;
 	struct req_lib_cpg_join req_lib_cpg_join;
 	struct res_lib_cpg_join res_lib_cpg_join;
 	struct res_lib_cpg_join res_lib_cpg_join;
-	struct req_lib_cpg_trackstart req_lib_cpg_trackstart;
-	struct res_lib_cpg_trackstart res_lib_cpg_trackstart;
 
 
 	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
 	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
 	if (error != CS_OK) {
 	if (error != CS_OK) {
 		return (error);
 		return (error);
 	}
 	}
 
 
-	pthread_mutex_lock (&cpg_inst->response_mutex);
-
-	/* Automatically add a tracker */
-	req_lib_cpg_trackstart.header.size = sizeof (struct req_lib_cpg_trackstart);
-	req_lib_cpg_trackstart.header.id = MESSAGE_REQ_CPG_TRACKSTART;
-	marshall_to_mar_cpg_name_t (&req_lib_cpg_trackstart.group_name,
-		group);
-
-	iov[0].iov_base = &req_lib_cpg_trackstart;
-	iov[0].iov_len = sizeof (struct req_lib_cpg_trackstart);
-
-	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
-		&res_lib_cpg_trackstart, sizeof (struct res_lib_cpg_trackstart));
-
-	if (error != CS_OK) {
-		pthread_mutex_unlock (&cpg_inst->response_mutex);
-		goto error_exit;
-	}
-
 	/* Now join */
 	/* Now join */
 	req_lib_cpg_join.header.size = sizeof (struct req_lib_cpg_join);
 	req_lib_cpg_join.header.size = sizeof (struct req_lib_cpg_join);
 	req_lib_cpg_join.header.id = MESSAGE_REQ_CPG_JOIN;
 	req_lib_cpg_join.header.id = MESSAGE_REQ_CPG_JOIN;
@@ -428,14 +407,18 @@ cs_error_t cpg_join (
 	iov[0].iov_base = &req_lib_cpg_join;
 	iov[0].iov_base = &req_lib_cpg_join;
 	iov[0].iov_len = sizeof (struct req_lib_cpg_join);
 	iov[0].iov_len = sizeof (struct req_lib_cpg_join);
 
 
-	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
-		&res_lib_cpg_join, sizeof (struct res_lib_cpg_join));
+	do {
+		pthread_mutex_lock (&cpg_inst->response_mutex);
 
 
-	pthread_mutex_unlock (&cpg_inst->response_mutex);
+		error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
+			&res_lib_cpg_join, sizeof (struct res_lib_cpg_join));
 
 
-	if (error != CS_OK) {
-		goto error_exit;
-	}
+		pthread_mutex_unlock (&cpg_inst->response_mutex);
+
+		if (error != CS_OK) {
+			goto error_exit;
+		}
+	} while (res_lib_cpg_join.header.error == CPG_ERR_BUSY);
 
 
 	error = res_lib_cpg_join.header.error;
 	error = res_lib_cpg_join.header.error;
 
 
@@ -469,15 +452,18 @@ cs_error_t cpg_leave (
 	iov[0].iov_base = &req_lib_cpg_leave;
 	iov[0].iov_base = &req_lib_cpg_leave;
 	iov[0].iov_len = sizeof (struct req_lib_cpg_leave);
 	iov[0].iov_len = sizeof (struct req_lib_cpg_leave);
 
 
-	pthread_mutex_lock (&cpg_inst->response_mutex);
+	do {
+		pthread_mutex_lock (&cpg_inst->response_mutex);
 
 
-	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
-		&res_lib_cpg_leave, sizeof (struct res_lib_cpg_leave));
+		error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
+			&res_lib_cpg_leave, sizeof (struct res_lib_cpg_leave));
 
 
-	pthread_mutex_unlock (&cpg_inst->response_mutex);
-	if (error != CS_OK) {
-		goto error_exit;
-	}
+		pthread_mutex_unlock (&cpg_inst->response_mutex);
+
+		if (error != CS_OK) {
+			goto error_exit;
+		}
+	} while (res_lib_cpg_leave.header.error == CPG_ERR_BUSY);
 
 
 	error = res_lib_cpg_leave.header.error;
 	error = res_lib_cpg_leave.header.error;
 
 
@@ -511,16 +497,18 @@ cs_error_t cpg_membership_get (
 	iov.iov_base = &req_lib_cpg_membership_get;
 	iov.iov_base = &req_lib_cpg_membership_get;
 	iov.iov_len = sizeof (coroipc_request_header_t);
 	iov.iov_len = sizeof (coroipc_request_header_t);
 
 
-	pthread_mutex_lock (&cpg_inst->response_mutex);
+	do {
+		pthread_mutex_lock (&cpg_inst->response_mutex);
 
 
-	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
-		&res_lib_cpg_membership_get, sizeof (coroipc_response_header_t));
+		error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
+			&res_lib_cpg_membership_get, sizeof (coroipc_response_header_t));
 
 
-	pthread_mutex_unlock (&cpg_inst->response_mutex);
+		pthread_mutex_unlock (&cpg_inst->response_mutex);
 
 
-	if (error != CS_OK) {
-		goto error_exit;
-	}
+ 		if (error != CS_OK) {
+ 			goto error_exit;
+		}
+	} while (res_lib_cpg_membership_get.header.error == CPG_ERR_BUSY);
 
 
 	error = res_lib_cpg_membership_get.header.error;
 	error = res_lib_cpg_membership_get.header.error;
 
 

ファイルの差分が大きいため隠しています
+ 336 - 476
services/cpg.c


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません