Created
April 8, 2013 17:34
-
-
Save tony2001/5338712 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/jobs.c b/src/jobs.c | |
index 3c72d80..273d427 100644 | |
--- a/src/jobs.c | |
+++ b/src/jobs.c | |
@@ -555,14 +555,24 @@ static inline void _trustd_job_add_friends(void *data) /* {{{ */ | |
__sync_fetch_and_add(&F->user_stats.is_searchable_cnt, new_is_searchable); | |
__sync_fetch_and_add(&F->user_stats.mem_circle1, (new_mem_circle1 - old_mem_circle1) + friend_mem_circle1_diff); | |
- if (u1_contacts_size > F->user_stats.max_contacts_cnt) { | |
- __sync_val_compare_and_swap(&F->user_stats.max_contacts_cnt, F->user_stats.max_contacts_cnt, u1_contacts_size); | |
- __sync_val_compare_and_swap(&F->user_stats.max_contacts_uid, F->user_stats.max_contacts_uid, job->uid); | |
+ while(1) { | |
+ if (u1_contacts_size > F->user_stats.max_contacts_cnt) { | |
+ if (__sync_bool_compare_and_swap(&F->user_stats.max_contacts_cnt, F->user_stats.max_contacts_cnt, u1_contacts_size)) { | |
+ __sync_bool_compare_and_swap(&F->user_stats.max_contacts_uid, F->user_stats.max_contacts_uid, job->uid); | |
+ } | |
+ } else { | |
+ break; | |
+ } | |
} | |
- if (u2_contacts_size > F->user_stats.max_contacts_cnt) { | |
- __sync_val_compare_and_swap(&F->user_stats.max_contacts_cnt, F->user_stats.max_contacts_cnt, u2_contacts_size); | |
- __sync_val_compare_and_swap(&F->user_stats.max_contacts_uid, F->user_stats.max_contacts_uid, friend_uid); | |
+ while(1) { | |
+ if (u2_contacts_size > F->user_stats.max_contacts_cnt) { | |
+ if (__sync_bool_compare_and_swap(&F->user_stats.max_contacts_cnt, F->user_stats.max_contacts_cnt, u2_contacts_size)) { | |
+ __sync_bol_compare_and_swap(&F->user_stats.max_contacts_uid, F->user_stats.max_contacts_uid, friend_uid); | |
+ } | |
+ } else { | |
+ break; | |
+ } | |
} | |
free(job_data->friends); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment