<table><tr><td style="">poboiko created this revision.<br />poboiko added a reviewer: dvratil.<br />Herald added a project: KDE PIM.<br />poboiko requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D28181">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>This patch is similar to <a href="https://phabricator.kde.org/D28178" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D28178: [contacts] Fix ContactCreateJob with a photo</a>. Although <tt style="background: #ebebeb; font-size: 13px;">uid</tt> is populated, and we can<br />
freely dispatch both contact and photo modify requests in parallel, the<br />
following race condition still sometimes happens:</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Contact modify request dispatched</li>
<li class="remarkup-list-item">Contact photo modify request dispatched</li>
<li class="remarkup-list-item">Photo reply arrives</li>
</ol>

<p>At this point, <tt style="background: #ebebeb; font-size: 13px;">d->lastContact</tt> is not yet populated, and we call<br />
<tt style="background: #ebebeb; font-size: 13px;">processNextContact()</tt>, which repeats steps 1 and 2 for the very same contact.<br />
Which could happen again and again, if photo reply arrives first again.</p>

<p>Instead, I suggest to fire photo modify request only after we receive reply<br />
for contact modify request, ensuring everything happens in the following order:</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Contact modify request dispatched</li>
<li class="remarkup-list-item">Contact modify reply received</li>
<li class="remarkup-list-item">Contact photo modify request dispatched</li>
<li class="remarkup-list-item">Contact photo reply received</li>
</ol></div></div><br /><div><strong>TEST PLAN</strong><div><ol class="remarkup-list">
<li class="remarkup-list-item">Modify a contact via KAddressBook</li>
<li class="remarkup-list-item">Check logs 3.1) (without patch) Bunch of modify requests somtimes gets fired 3.2) (with patch) Only one modify request gets fired</li>
</ol></div></div><br /><div><strong>REPOSITORY</strong><div><div>R477 KGAPI Library</div></div></div><br /><div><strong>BRANCH</strong><div><div>no-race-modify (branched from master)</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D28181">https://phabricator.kde.org/D28181</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/contacts/contactmodifyjob.cpp</div></div></div><br /><div><strong>To: </strong>poboiko, dvratil<br /><strong>Cc: </strong>kde-pim, fbampaloukas, dcaliste, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss, dvratil<br /></div>