On 16/01/2015 09:03, Pavel Dovgaluk wrote:
> There is one problem with protecting log file inside the replay code.
> We probably should have the following sequence of calls:
> 
> lock_replay_mutex
> replay_save_events
>     replay_run_event
> unlock_replay_mutex
> 
> But replay_run_event can also generate some log events and we will have 
> deadlock here.
> That is why we rely on global mutex.

I think replay_run_event should run with the lock _not_ taken, that is:

    qemu_mutex_lock(&lock);
    while (!QTAILQ_EMPTY(&events_list)) {
        Event *event = QTAILQ_FIRST(&events_list);
        QTAILQ_REMOVE(&events_list, event, events);
        qemu_mutex_unlock(&lock);
        replay_run_event(event);
        g_free(event);
        qemu_mutex_lock(&lock);
    }
    qemu_mutex_unlock(&lock);

Paolo

Reply via email to