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;