From 7c8cdfb197658ecada14bc72dfa1e2a718f26b46 Mon Sep 17 00:00:00 2001 From: Jan Friesse Date: Tue, 12 Oct 2010 13:03:37 +0000 Subject: [PATCH] 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 --- exec/coroipcs.c | 7 +++++++ include/corosync/coroipc_ipc.h | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/exec/coroipcs.c b/exec/coroipcs.c index f246c8f7..0ca22d30 100644 --- a/exec/coroipcs.c +++ b/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); diff --git a/include/corosync/coroipc_ipc.h b/include/corosync/coroipc_ipc.h index c3c2d23a..dadc34f4 100644 --- a/include/corosync/coroipc_ipc.h +++ b/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;