Bläddra i källkod

Remove delay in library on corosync shutdown

Patch removes 2 seconds delay in library on normal corosync shutdown.
Delay is still present on abnormal shutdown.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@3059 fd59a12c-fef9-0310-b244-a6a79926bd2f
Jan Friesse 15 år sedan
förälder
incheckning
7c8cdfb197
2 ändrade filer med 17 tillägg och 1 borttagningar
  1. 7 0
      exec/coroipcs.c
  2. 10 1
      include/corosync/coroipc_ipc.h

+ 7 - 0
exec/coroipcs.c

@@ -547,6 +547,13 @@ static inline int conn_info_destroy (struct conn_info *conn_info)
 	list_del (&conn_info->list);
 	pthread_mutex_unlock (&conn_info->mutex);
 
+	/*
+	 * Let library know, that connection is now closed
+	 */
+	conn_info->control_buffer->ipc_closed = 1;
+	ipc_sem_post (conn_info->control_buffer, SEMAPHORE_RESPONSE);
+	ipc_sem_post (conn_info->control_buffer, SEMAPHORE_DISPATCH);
+
 #if _POSIX_THREAD_PROCESS_SHARED > 0
 	sem_destroy (&conn_info->control_buffer->sem_request_or_flush_or_exit);
 	sem_destroy (&conn_info->control_buffer->sem_request);

+ 10 - 1
include/corosync/coroipc_ipc.h

@@ -92,6 +92,7 @@ struct control_buffer {
 #else
 	int semid;
 #endif
+	int ipc_closed;
 };
 
 enum res_init_types {
@@ -202,7 +203,11 @@ retry_sem_wait:
 		if (res == -1) {
 			return (CS_ERR_LIBRARY);
 		}
-	} else { 
+	} else {
+		if (control_buffer->ipc_closed) {
+			return (CS_ERR_LIBRARY);
+		}
+
 		timeout.tv_sec = time(NULL) + IPC_SEMWAIT_TIMEOUT;
 		timeout.tv_nsec = 0;
 
@@ -243,6 +248,10 @@ retry_poll:
 		if (res == -1) {
 			return (CS_ERR_LIBRARY);
 		}
+
+		if (res == 0 && control_buffer->ipc_closed) {
+			return (CS_ERR_LIBRARY);
+		}
 	}
 #else
 	sop.sem_num = sem_id;