Skip to content
  • Igor Poboiko's avatar
    [contacts/ContactModifyJob] Avoid race condition · dfb1afc6
    Igor Poboiko authored
    Summary:
    This patch is similar to {D28178}. Although `uid` is populated, and we can
    freely dispatch both contact and photo modify requests in parallel, the
    following race condition still sometimes happens:
    
     1) Contact modify request dispatched
     2) Contact photo modify request dispatched
     3) Photo reply arrives
    
    At this point, `d->lastContact` is not yet populated, and we call
    `processNextContact()`, which repeats steps 1 and 2 for the very same contact.
    Which could happen again and again, if photo reply arrives first again.
    
    Instead, I suggest to fire photo modify request only after we receive reply
    for contact modify request, ensuring everything happens in the following order:
    
     1) Contact modify request dispatched
     2) Contact modify reply received
     3) Contact photo modify request dispatched
     4) Contact photo reply received
    
    Test Plan:
     1) Modify a contact via KAddressBook
     2) Check logs
     3) (without patch) Bunch of modify requests somtimes gets fired
     4) (with patch) Only one modify request gets fired
    
    Reviewers: dvratil
    
    Reviewed By: dvratil
    
    Subscribers: kde-pim
    
    Tags: #kde_pim
    
    Differential Revision: https://phabricator.kde.org/D28181
    dfb1afc6