فهرست منبع

Merge trunk revision 2394:
r2394 | sdake | 2009-08-24 10:50:12 -0700 (Mon, 24 Aug 2009) | 2 lines

Allow finalize routines to occur inside dispatch routines.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/branches/flatiron@2445 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 16 سال پیش
والد
کامیت
e4bbf0e920
2فایلهای تغییر یافته به همراه52 افزوده شده و 4 حذف شده
  1. 43 0
      include/corosync/hdb.h
  2. 9 4
      lib/coroipcc.c

+ 43 - 0
include/corosync/hdb.h

@@ -260,6 +260,49 @@ static inline int hdb_handle_get (
 	return (0);
 	return (0);
 }
 }
 
 
+static inline int hdb_handle_get_always (
+	struct hdb_handle_database *handle_database,
+	hdb_handle_t handle_in,
+	void **instance)
+{
+	unsigned int check = ((unsigned int)(((unsigned long long)handle_in) >> 32));
+	unsigned int handle = handle_in & 0xffffffff;
+
+	if (handle_database->first_run == 1) {
+		handle_database->first_run = 0;
+		hdb_database_lock_init (&handle_database->lock);
+	}
+	hdb_database_lock (&handle_database->lock);
+
+	*instance = NULL;
+	if (handle >= handle_database->handle_count) {
+		hdb_database_unlock (&handle_database->lock);
+		errno = EBADF;
+		return (-1);
+	}
+
+	if (handle_database->handles[handle].state == HDB_HANDLE_STATE_EMPTY) {
+		hdb_database_unlock (&handle_database->lock);
+		errno = EBADF;
+		return (-1);
+	}
+
+	if (check != 0xffffffff &&
+		check != handle_database->handles[handle].check) {
+
+		hdb_database_unlock (&handle_database->lock);
+		errno = EBADF;
+		return (-1);
+	}
+
+	*instance = handle_database->handles[handle].instance;
+
+	handle_database->handles[handle].ref_count += 1;
+
+	hdb_database_unlock (&handle_database->lock);
+	return (0);
+}
+
 static inline int hdb_handle_put (
 static inline int hdb_handle_put (
 	struct hdb_handle_database *handle_database,
 	struct hdb_handle_database *handle_database,
 	hdb_handle_t handle_in)
 	hdb_handle_t handle_in)

+ 9 - 4
lib/coroipcc.c

@@ -890,7 +890,7 @@ coroipcc_dispatch_put (hdb_handle_t handle)
 	char *addr;
 	char *addr;
 	unsigned int read_idx;
 	unsigned int read_idx;
 
 
-	res = hdb_error_to_cs (hdb_handle_get (&ipc_hdb, handle, (void **)&ipc_instance));
+	res = hdb_error_to_cs (hdb_handle_get_always (&ipc_hdb, handle, (void **)&ipc_instance));
 	if (res != CS_OK) {
 	if (res != CS_OK) {
 		return (res);
 		return (res);
 	}
 	}
@@ -907,14 +907,16 @@ retry_semwait:
 retry_semop:
 retry_semop:
 	res = semop (ipc_instance->semid, &sop, 1);
 	res = semop (ipc_instance->semid, &sop, 1);
 	if (res == -1 && errno == EINTR) {
 	if (res == -1 && errno == EINTR) {
-		return (CS_ERR_TRY_AGAIN);
+		res = CS_ERR_TRY_AGAIN;
+		goto error_exit;
 	} else
 	} else
 	if (res == -1 && errno == EACCES) {
 	if (res == -1 && errno == EACCES) {
 		priv_change_send (ipc_instance);
 		priv_change_send (ipc_instance);
 		goto retry_semop;
 		goto retry_semop;
 	} else
 	} else
 	if (res == -1) {
 	if (res == -1) {
-		return (CS_ERR_LIBRARY);
+		res = CS_ERR_LIBRARY;
+		goto error_exit;
 	}
 	}
 #endif
 #endif
 
 
@@ -927,10 +929,13 @@ retry_semop:
 	/*
 	/*
 	 * Put from dispatch get and also from this call's get
 	 * Put from dispatch get and also from this call's get
 	 */
 	 */
+	res = CS_OK;
+	
+error_exit:
 	hdb_handle_put (&ipc_hdb, handle);
 	hdb_handle_put (&ipc_hdb, handle);
 	hdb_handle_put (&ipc_hdb, handle);
 	hdb_handle_put (&ipc_hdb, handle);
 
 
-	return (CS_OK);
+	return (res);
 }
 }
 
 
 cs_error_t
 cs_error_t