summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-09-08 10:03:35 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-09-08 10:03:35 +0900
commitc1556b711239193cb7a63be3f647e185da83134d (patch)
treeabfb26bc52b8dd13c0a8d1d4677760619396a36c
parentc598997299a77c7a788ac66f55e556abd010dc42 (diff)
eina - remove deadlock from share-common + remove extra lock/unlock
-rw-r--r--src/lib/eina/eina_share_common.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/lib/eina/eina_share_common.c b/src/lib/eina/eina_share_common.c
index 0dbf37d5f9..c2b64acc75 100644
--- a/src/lib/eina/eina_share_common.c
+++ b/src/lib/eina/eina_share_common.c
@@ -236,11 +236,9 @@ _eina_share_common_population_stats(Eina_Share *share)
236 share->population_group[i].max); 236 share->population_group[i].max);
237} 237}
238 238
239void 239static void
240eina_share_common_population_add(Eina_Share *share, int slen) 240eina_share_common_population_nolock_add(Eina_Share *share, int slen)
241{ 241{
242 eina_lock_take(&_mutex_big);
243
244 share->population.count++; 242 share->population.count++;
245 if (share->population.count > share->population.max) 243 if (share->population.count > share->population.max)
246 share->population.max = share->population.count; 244 share->population.max = share->population.count;
@@ -253,19 +251,29 @@ eina_share_common_population_add(Eina_Share *share, int slen)
253 share->population_group[slen].max = 251 share->population_group[slen].max =
254 share->population_group[slen].count; 252 share->population_group[slen].count;
255 } 253 }
256
257 eina_lock_release(&_mutex_big);
258} 254}
259 255
260void 256void
261eina_share_common_population_del(Eina_Share *share, int slen) 257eina_share_common_population_add(Eina_Share *share, int slen)
262{ 258{
263 eina_lock_take(&_mutex_big); 259 eina_lock_take(&_mutex_big);
260 eina_share_common_population_nolock_add(share, slen);
261 eina_lock_release(&_mutex_big);
262}
264 263
264static void
265eina_share_common_population_nolock_del(Eina_Share *share, int slen)
266{
265 share->population.count--; 267 share->population.count--;
266 if (slen < 4) 268 if (slen < 4)
267 share->population_group[slen].count--; 269 share->population_group[slen].count--;
270}
268 271
272void
273eina_share_common_population_del(Eina_Share *share, int slen)
274{
275 eina_lock_take(&_mutex_big);
276 eina_share_common_population_nolock_del(chare, slen);
269 eina_lock_release(&_mutex_big); 277 eina_lock_release(&_mutex_big);
270} 278}
271 279
@@ -301,9 +309,15 @@ static void _eina_share_common_population_shutdown(EINA_UNUSED Eina_Share *share
301} 309}
302static void _eina_share_common_population_stats(EINA_UNUSED Eina_Share *share) { 310static void _eina_share_common_population_stats(EINA_UNUSED Eina_Share *share) {
303} 311}
312static void eina_share_common_population_nolock_add(EINA_UNUSED Eina_Share *share,
313 EINA_UNUSED int slen) {
314}
304void eina_share_common_population_add(EINA_UNUSED Eina_Share *share, 315void eina_share_common_population_add(EINA_UNUSED Eina_Share *share,
305 EINA_UNUSED int slen) { 316 EINA_UNUSED int slen) {
306} 317}
318static void eina_share_common_population_nolock_del(EINA_UNUSED Eina_Share *share,
319 EINA_UNUSED int slen) {
320}
307void eina_share_common_population_del(EINA_UNUSED Eina_Share *share, 321void eina_share_common_population_del(EINA_UNUSED Eina_Share *share,
308 EINA_UNUSED int slen) { 322 EINA_UNUSED int slen) {
309} 323}
@@ -801,9 +815,9 @@ eina_share_common_ref(Eina_Share *share, const char *str)
801 } 815 }
802 node->references++; 816 node->references++;
803 817
804 eina_lock_release(&_mutex_big); 818 eina_share_common_population_nolock_add(share, node->length);
805 819
806 eina_share_common_population_add(share, node->length); 820 eina_lock_release(&_mutex_big);
807 821
808 return str; 822 return str;
809} 823}
@@ -827,7 +841,7 @@ eina_share_common_del(Eina_Share *share, const char *str)
827 goto on_error; 841 goto on_error;
828 842
829 slen = node->length; 843 slen = node->length;
830 eina_share_common_population_del(share, slen); 844 eina_share_common_population_nolock_del(share, slen);
831 if (node->references > 1) 845 if (node->references > 1)
832 { 846 {
833 node->references--; 847 node->references--;