Fix segfault
authorAlex Pyrgiotis <apyrgio@grnet.gr>
Mon, 11 Feb 2013 07:00:08 +0000 (09:00 +0200)
committerFilippos Giannakos <philipgian@grnet.gr>
Mon, 11 Mar 2013 09:43:58 +0000 (11:43 +0200)
xseg/peers/user/peer.c

index 9c6ce94..1d88d2d 100644 (file)
@@ -448,12 +448,11 @@ int peerd_start_threads(struct peerd *peer)
                peer->thread[i].arg = NULL;
        }
 
+       if (peer->interactive_func)
+               peer->interactive_func();
        for (i = 0; i < nr_threads; i++) {
                pthread_join(peer->thread[i].tid, NULL);
        }
-       //?: Is this re-ordering acceptable?
-       if (peer->interactive_func)
-               peer->interactive_func();
 
        return 0;
 }
@@ -799,12 +798,10 @@ int main(int argc, char *argv[])
        r = custom_peer_init(peer, argc, argv);
        if (r < 0)
                goto out;
-#ifdef MT
+#if defined(MT)
        //TODO err check
        peerd_start_threads(peer);
-#endif
-
-#ifdef ST_THREADS
+#elif defined(ST_THREADS)
        st_thread_t st = st_thread_create(peerd_loop, peer, 1, 0);
        r = st_thread_join(st, NULL);
 #else