Hi, Another issue we found upgrading was that the code doesn't compile when _POSIX_THREAD_PROCESS_SHARED < 1. When it does compile, it crashes on our system - our version of uClibc seems to always expect a 4th arg. The man pages suggests the 4th arg is optional, but does say: 'For greater portability it is best to always call semctl() with four arguments'. The attached patch does this.
Cheers, Tim
From: Tim Beale <tim.be...@alliedtelesis.co.nz> Fix compile/runtime issues for _POSIX_THREAD_PROCESS_SHARED < 1 For the case where _POSIX_THREAD_PROCESS_SHARED < 1, the code doesn't compile for corosync v1.3.1. And when it does compile, it crashes on our system - our version of uClibc seems to always expect a 4th arg. The man pages suggests the 4th arg is optional, but does say: 'For greater portability it is best to always call semctl() with four arguments', which is what this patch does. Also removed semop as it's an unused variable. --- exec/coroipcs.c | 11 ----------- include/corosync/coroipc_ipc.h | 17 +++++++++++------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/exec/coroipcs.c b/exec/coroipcs.c index d55fc42..fb944bd 100644 --- a/exec/coroipcs.c +++ b/exec/coroipcs.c @@ -119,17 +119,6 @@ struct zcb_mapped { size_t size; }; -#if _POSIX_THREAD_PROCESS_SHARED < 1 -#if defined(_SEM_SEMUN_UNDEFINED) -union semun { - int val; - struct semid_ds *buf; - unsigned short int *array; - struct seminfo *__buf; -}; -#endif -#endif - enum conn_state { CONN_STATE_THREAD_INACTIVE = 0, CONN_STATE_THREAD_ACTIVE = 1, diff --git a/include/corosync/coroipc_ipc.h b/include/corosync/coroipc_ipc.h index dadc34f..9adaed8 100644 --- a/include/corosync/coroipc_ipc.h +++ b/include/corosync/coroipc_ipc.h @@ -57,6 +57,15 @@ #include <semaphore.h> #else #include <sys/sem.h> + +#if defined(_SEM_SEMUN_UNDEFINED) +union semun { + int val; + struct semid_ds *buf; + unsigned short int *array; + struct seminfo *__buf; +}; +#endif #endif /* @@ -330,8 +339,8 @@ ipc_sem_getvalue ( int *sem_value) { #if _POSIX_THREAD_PROCESS_SHARED < 1 - struct sembuf sop; int sem_value_hold; + union semun semun; #else sem_t *sem = NULL; int res; @@ -358,12 +367,8 @@ ipc_sem_getvalue ( return (CS_ERR_LIBRARY); } #else - sop.sem_num = sem_id; - sop.sem_op = 1; - sop.sem_flg = 0; - retry_semctl: - sem_value_hold = semctl (control_buffer->semid, sem_id, GETVAL); + sem_value_hold = semctl (control_buffer->semid, sem_id, GETVAL, semun); if (sem_value_hold == -1 && errno == EINTR) { goto retry_semctl; } else
_______________________________________________ Openais mailing list Openais@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/openais