Changeset 1046

Show
Ignore:
Timestamp:
06/09/06 06:16:50 (2 years ago)
Author:
ehabkost
Message:

Drop queue->pendingLock before calling the reply callback

The reply callback may end up calling osync_queue_send_message().
We will hang if the lock is kept held during the call.

Signed-off-by: Eduardo Habkost <ehabkost@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/ipc-branch/opensync/opensync_queue.c

    r1045 r1046  
    7878                         * list since another thread might be duing the updates */ 
    7979                        g_mutex_lock(queue->pendingLock); 
     80 
     81                        OSyncPendingMessage *found = NULL; 
    8082                         
    8183                        GList *p = NULL; 
     
    8486                                 
    8587                                if (pending->id1 == message->id1 && pending->id2 == message->id2) { 
    86                                          
    87                                         /* Call the callback of the pending message */ 
    88                                         osync_assert(pending->callback); 
    89                                         pending->callback(message, pending->user_data); 
    90                                          
    91                                         /* Then remove the pending message and free it */ 
     88 
     89                                        /* Get the pending message from the queue */ 
    9290                                        queue->pendingReplies = g_list_remove(queue->pendingReplies, pending); 
    93                                         g_free(pending); 
     91                                        found = pending; 
    9492                                        break; 
    9593                                } 
    9694                        } 
    97                          
    9895                        g_mutex_unlock(queue->pendingLock); 
     96 
     97                        if (found) { 
     98                                /* Call the callback of the pending message and free the message */ 
     99                                osync_assert(found->callback); 
     100                                found->callback(message, found->user_data); 
     101                                 
     102                                g_free(found); 
     103                        } else 
     104                                osync_trace(TRACE_INTERNAL, "%s: No pending message for %lld:%d", __func__, message->id1, message->id2); 
     105 
    99106                } else  
    100107                        queue->message_handler(message, queue->user_data);