Thursday, March 05, 2020

Re: pthread_mutexattr_setpshared and Apache Guacamole remote desktop gateway

On 05/03/2020 10:53 a.m., Edgar Pettijohn wrote:
> On Mar 5, 2020 10:15 AM, Steve Williams <steve@williamsitconsulting.com> wrote:
>> Hi,
>>
>> Should this be on ports@?  I'm not working on a port...
>>
>> TL;DR:
>> Does anyone have any recommendations on how to work around not having
>> pthread_mutexattr_setpshared in the OpenBSD pthreads library?
>>
> Have you tried searching the ports tree patch files for mention of the function. You may find a real world example of a workaround.
>
> Edgar
>
>> DETAILS:
>> I wanted to see if Apache Guacamole would compile on OpenBSD to server
>> as a remote desktop gateway.
>>
>> It hasn't been too hard to get it to the final linking step.
>>
>> I am getting an "undefined reference to `pthread_mutexattr_setpshared'":
>>
>>     ../../src/libguac/.libs/libguac.so.17.0: undefined reference to
>>     `pthread_mutexattr_setpshared'
>>     collect2: ld returned 1 exit status
>>     *** Error 1 in src/guacenc (Makefile:565 'guacenc': @echo " CCLD
>>     " guacenc;/bin/sh ../../libtool --silent --tag=CC --mode=link gcc -s...)
>>     *** Error 1 in . (Makefile:556 'all-recursive')
>>     *** Error 1 in /home/steve/src/guacamole-server-1.1.0 (Makefile:453
>>     'all')
>>
>>
>> When I look at some of the code using pthread_mutexattr_setpshared, it's
>> not #ifdef'd or anything, so I think it's pretty much mandatory code.
>>
>> pool.c:
>>
>>     guac_pool* guac_pool_alloc(int size) {
>>
>>          pthread_mutexattr_t lock_attributes;
>>          guac_pool* pool = malloc(sizeof(guac_pool));
>>
>>          /* If unable to allocate, just return NULL. */
>>          if (pool == NULL)
>>              return NULL;
>>
>>          /* Initialize empty pool */
>>          pool->min_size = size;
>>          pool->active = 0;
>>          pool->__next_value = 0;
>>          pool->__head = NULL;
>>          pool->__tail = NULL;
>>
>>          /* Init lock */
>>          pthread_mutexattr_init(&lock_attributes);
>>
>>          pthread_mutexattr_setpshared(&lock_attributes,
>>     PTHREAD_PROCESS_SHARED);
>>     //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>          pthread_mutex_init(&(pool->__lock), &lock_attributes);
>>
>>
>> It looks like this is a posix (of some version) function:
>> https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutexattr_setpshared.html
>>
>> An "appropos" search in the OpenBSD man pages for "pthread_mutexattr"
>> returned:
>> https://man.openbsd.org/man3/pthread_mutexattr.3
>>
>> This function is definitely missing...
>>
>> I tried to see if there was a way to use pthread_mutexattr_settype to
>> accomplish the same thing, but got lost in the maze of documentation.
>>
>> Does anyone have any recommendations on how to work around not having
>> pthread_mutexattr_setpshared in the OpenBSD pthreads library?
>>
>> Thanks,
>> Steve Williams
>>

Hi,

Great idea to check the ports tree patch files!

I will start to look through these and see how they are handling
things.   I have deleted all the lines returned for posixtestsuite port.

$ find . -type f -print0 | xargs -0 grep pthread_mutexattr_setpshared |
tee /tmp/shared.out

./databases/virtuoso/patches/patch-libsrc_Thread_sched_pthread_c: rc =
pthread_mutexattr_setpshared (&_mutex_attr, PTHREAD_PROCESS_PRIVATE);
./databases/virtuoso/patches/patch-libsrc_Thread_sched_pthread_c: rc =
pthread_mutexattr_setpshared (&_mutex_attr, PTHREAD_PROCESS_PRIVATE);
./databases/virtuoso/patches/patch-libsrc_Thread_sched_pthread_c: rc =
pthread_mutexattr_setpshared (&_attr, PTHREAD_PROCESS_PRIVATE);
./devel/lam/patches/patch-config_lam_mutex_pshared_m4:   if
(pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED)) return(1);
./textproc/sphinx/patches/patch-src_sphinxstd_cpp:-     iRes =
pthread_mutexattr_setpshared ( &tAttr, PTHREAD_PROCESS_SHARED );
./textproc/sphinx/patches/patch-src_sphinxstd_cpp:- m_sError.SetSprintf
( "pthread_mutexattr_setpshared, errno = %d", iRes );
./x11/kde4/libs/files/ConfigureChecks.cmake:    if
(pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED) == -1) {
./x11/kde4/libs/files/ConfigureChecks.cmake:
printf(\"pthread_mutexattr_setpshared failed: %s\", strerror(errno));
./x11/kde4/libs/patches/patch-kdecore_util_kshareddatacache_p_h: if
(pthread_mutexattr_setpshared(&mutexAttr, PTHREAD_PROCESS_SHARED) == 0 &&

Cheers,
Steve Williams

No comments:

Post a Comment