Page 1 of 1

Server hangs when compiled without CURL (edited)

Posted: Sat Mar 30, 2013 2:37 pm
by Reven
I've compiled the server (version 1.70) on an HPPA (PA-RISC) machine running Debian. When I try to connect a client to it, the connection fails silently. No error message on client or server. On the client the connection dialog disappears for about five seconds, then it comes back.

Network-wise, I can see the connection is made, one data packet is sent from client to server, then the client disconnects, presumably because the server never responded. The connection is successful, and the one packet sent from client to server is acknowledged, so I know the server is getting it.

At this point I am suspecting an endian issue. Does anyone have the server successfully running on a big-endian machine?

Posted: Sun Mar 31, 2013 7:33 pm
by Reven
I found the bug. It's not an endian issue. It's the use of an uninitialized mutex.

The initialization of ms2_info_mutex, in metaserer.c:metaserver2_init() is behind an #ifdef:

Code: Select all

#ifdef HAVE_CURL_CURL_H
    if (!has_init) {
        memset(&local_info, 0, sizeof(LocalMeta2Info));
        memset(&metaserver2_updateinfo, 0, sizeof(MetaServer2_UpdateInfo));

        local_info.portnumber = settings.csport;
        metaserver2 = NULL;
        pthread_mutex_init(&ms2_info_mutex, NULL);
...but the use of that mutex in metaserver.c:metaserver_update() is not behind the same #ifdef.

Posted: Mon Apr 01, 2013 5:57 pm
by Leaf
What happens when you specific the server when launching the client?

ie,
./client.svn/gtk-v2/src/crossfire-client-gtk2 -server 127.0.0.1

Does the client connect to the server okay or does it still hang?

Posted: Wed Apr 10, 2013 2:58 pm
by Reven
I should have updated this earlier.

First...
Leaf wrote:What happens when you specific the server when launching the client ... Does the client connect to the server okay or does it still hang?
Yes the client hangs. I verified with gdb that the server was stuck at the pthread_mutex_lock() call in metaserver_update(). That lock never ever returns because the mutex was uninitialized since I didn't have curl at the time.

I subsequently put all the metaserver update code behind the same #ifdef that the initialization code was behind, and it works fine. Fix is checked into CVS.

Of course Leaf knows all this already, but for anyone else who might come along...