ClusterLabs / libqb

libqb is a library providing high performance logging, tracing, ipc, and poll.
http://clusterlabs.github.io/libqb/
GNU Lesser General Public License v2.1
165 stars 98 forks source link

Compilation fault on OS without sem_timedwait function #31

Closed jfriesse closed 12 years ago

jfriesse commented 12 years ago

Typical example is NetBSD, but I believe same problem appears in OpenBSD and Darwin. Compilation of libqb timerlist_helper file will fail, because this doesn't implement sem_timedwait function.

In corosync 1.x (flatiron) I've solved this issue by not using sem_timedwait on OS without it's support. Even this is not perfect solution, it made corosync somehow works in most situations.

Another option to explore may be to use threads.

asalkeld commented 12 years ago

I think we can work around the problem in the short term by:

1) in the ringbuffer when neither QB_RB_FLAG_SHARED_PROCESS nor QB_RB_FLAG_SHARED_THREAD are set (like in the blackbox) just don't use semaphores at all. 2) on platforms like this just don't support QB_IPC_SHM but rather use QB_IPC_SOCKET.

3) I'de also like to investigate implementing a counting sem with pthread_cond_timedwait and a counter in shared mem

Here is an example (LGPL) http://sipxecs.sipfoundry.org/rep/sipXecs/branches/3.10/sipXportLib/src/os/linux/pt_csem.c

asalkeld commented 12 years ago

Honzaf I have that pt_csem.c somewhat working, needs some more work. But looks promising.

asalkeld commented 12 years ago

Well that will work well for the in process semaphores but not shared process semaphores. I think I'll commit what I have (it will work for blackbox ringbuffer) and then in corosync use the socket type on bsd.

asalkeld commented 12 years ago

Honza would you mind testing the bsd branch?

Andrew Beekhof lent me a mac mini, but I would like to know it sorts your particular issue.

I have just pushed this to the bsd branch: https://github.com/asalkeld/libqb/commit/1af214d91da2870c300c873d6033e81b80c2e7dd

Note: in corosync can you change QB_IPC_SHM to QB_IPC_NATIVE (it will choose SHM if possible else SOCKET). The one thing I am unsure of is the usability of shared mutexes and cond variables on these targets. If you find that they do not support pshared then can you edit configure.ac and in the bsd case add:

AC_DEFINE_UNQUOTED([DISABLE_POSIX_THREAD_PROCESS_SHARED], [1],
                   [Disable _POSIX_THREAD_PROCESS_SHARED])