bugmldonkey, a multi-networks file-sharing client - Bugs: bug #37075, mldonkey fails to compile upnp...


You are not allowed to post comments on this tracker with your current authentification level.

bug #37075: mldonkey fails to compile upnp libraries on Mac OSX due to pthread_mutex_timedlock()

Submitted by:  Thruth Wang <thruth>
Submitted on:  Sat Aug 11 14:34:40 2012  
Category: NoneSeverity: 3 - Normal
Item Group: Compilation problemStatus: Duplicate
Assigned to: NoneOpen/Closed: Closed
Release: Release: 3.1.2
Operating System: NoneBinaries Origin: CVS / Self compiled
CPU type: x86_64

Sun Sep 1 15:52:01 2013, comment #4:

The other patch was commited to CVS some time ago. Thanks for your input!

ygrek <ygrek>
Project Member
Sun May 19 07:44:29 2013, comment #3:

NB there is also the patch along the same lines at

ygrek <ygrek>
Project Member
Mon Apr 15 19:50:50 2013, comment #2:

Patch attached. good with mldonkey 3.1.3 & OSX 10.7.x/10.8.x . Should not affect other platforms.

Thruth Wang <thruth>
Sat Oct 20 12:14:16 2012, comment #1:

My suggestion of removing the use of "pthread_mutex_timedlock()" is problematic, causing mlnet to consume 100% CPU after enabling upnp port forwarding.

So by briefly implementing pthread_mutex_timedlock(), in my project I got it to work on Mac 10.8.2. Compiled good, got uPNP forwarding success and fairly normal CPU usage. After some more testing & cleanup I'll provide the patch.

Thruth Wang <thruth>
Sat Aug 11 14:34:40 2012, original submission:

With '--enable-force-upnp-natpmp' present when ./configure, mldonkey will report no error in the configure phase but will fail in building mlnet binary:

Compile time error:
Undefined symbols for architecture x86_64:
"_pthread_mutex_timedlock", referenced from:
_upnpNatpmpThread in upnp_stubs.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking
make: *** [mlnet] Error 2

This is because of the use of pthread_mutex_timedlock() in src/utils/net/upnp_stubs.c line 874, plus that Mac OSX has not implemented pthread_mutex_timedlock() from 10.4 (or even earlier) to the latest 10.8. Here is a somewhat complete explanation of the situation: http://lists.apple.com/archives/Unix-porting/2008/Jan/msg00014.html

What mldonkey might want to do is that:

Detecting support for pthread_mutex_timedlock() in configure scripts, when the support is not available, removing the only call for pthread_mutex_timedlock() in "src/utils/net/upnp_stubs.c".

Specifically from LINE 871:
if ( g_running ){
deltatime.tv_sec = time(NULL) + 30;
deltatime.tv_nsec = 0;
dbg_printf("%d seconds timedlock, running...\n", deltatime.tv_sec);

I am not even a developer so I have no idea how to achieve above logic... But in such a way, Mac OSX users get a build success for mldonkey with upnp libs. The only compromise is the absence of a number in debug log.

If there is anything I can do please let me know. Thanks.

btw. Seems that Android has no pthread_mutex_timedlock() implementation either.

Thruth Wang <thruth>


Attached Files
file #27884:  macosx_pthread_mutex_timedlock_fix_mlnet313.patch added by thruth (1kB - application/octet-stream - Here comes the patch. Compiled and tested good with OSX 10.7.x and 10.8.2 - 10.8.3. And survived thousands of beta users using SpeedTao as GUI of mlnet.)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by ygrek (Posted a comment)
  • -unavailable- added by thruth (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun Sep 1 15:52:01 2013ygrekStatusNone=>Duplicate
    Mon Apr 15 19:49:01 2013thruthAttached File-=>Added macosx_pthread_mutex_timedlock_fix_mlnet313.patch, #27884

    Back to the top

    Powered by Savane 3.1-cleanup