Index: src/icqd-threads.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd-threads.cpp,v
retrieving revision 1.22
diff -u -b -p -r1.22 icqd-threads.cpp
--- src/icqd-threads.cpp	18 Jan 2003 01:29:32 -0000	1.22
+++ src/icqd-threads.cpp	24 Jan 2003 03:20:38 -0000
@@ -48,7 +48,6 @@ void *ProcessRunningEvent_Server_tep(voi
   static pthread_mutex_t send_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 
-
   /* want to be cancelled immediately so we don't try to derefrence the event
      after it has been deleted */
   pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
@@ -60,6 +59,7 @@ void *ProcessRunningEvent_Server_tep(voi
   if (!d) pthread_exit(NULL);
 
   // Must send packets in sequential order
+  pthread_mutex_lock(&send_mutex);
   pthread_mutex_lock(&d->mutex_sendqueue_server);
 
   list<ICQEvent *>::iterator iter;
@@ -88,6 +88,7 @@ void *ProcessRunningEvent_Server_tep(voi
 
     if (e == NULL)
     {
+      pthread_mutex_unlock(&send_mutex);
       pthread_mutex_unlock(&d->mutex_sendqueue_server);
       pthread_exit(NULL);
     }
@@ -106,7 +107,7 @@ void *ProcessRunningEvent_Server_tep(voi
   e->thread_send = pthread_self();
   e->thread_running = true;
 
-  pthread_mutex_lock(&send_mutex);
+  pthread_mutex_unlock(&d->mutex_sendqueue_server);
 
   // declared here because pthread_cleanup_push starts a new block
   CBuffer *buf;
@@ -115,7 +116,6 @@ void *ProcessRunningEvent_Server_tep(voi
 
   pthread_cleanup_push(cleanup_mutex, &send_mutex);
 
-    pthread_mutex_unlock(&d->mutex_sendqueue_server);
     pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
     pthread_testcancel();
 
