summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2011-05-18 07:58:43 +0000
committerCedric BAIL <cedric.bail@free.fr>2011-05-18 07:58:43 +0000
commit2800ec3f983a6e905dc6e805aa968658c369eff1 (patch)
tree1116cbb965abf58341f586c6c4856b8e4648dbb0
parent781977dae2152acfe2053d6f10b42cd61f6f17e7 (diff)
eina: backport 59485.
SVN revision: 59486
-rw-r--r--ChangeLog5
-rw-r--r--src/lib/eina_share_common.c19
2 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 96ea41b..a8c8621 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,6 @@
2 2
3 1.0.0 release 3 1.0.0 release
4 4
5
62011-03-09 Cedric Bail 52011-03-09 Cedric Bail
7 6
8 * Fix stat failure when file size in bytes or the number of blocks 7 * Fix stat failure when file size in bytes or the number of blocks
@@ -15,3 +14,7 @@
152011-04-27 Vincent Torri 142011-04-27 Vincent Torri
16 15
17 * Fix static build of the buddy mempool 16 * Fix static build of the buddy mempool
17
182011-05-18 Cedric Bail
19
20 * Fix eina_share_common_init to be called only once.
diff --git a/src/lib/eina_share_common.c b/src/lib/eina_share_common.c
index 86fb377..0a8d257 100644
--- a/src/lib/eina_share_common.c
+++ b/src/lib/eina_share_common.c
@@ -96,6 +96,7 @@
96static const char EINA_MAGIC_SHARE_STR[] = "Eina Share"; 96static const char EINA_MAGIC_SHARE_STR[] = "Eina Share";
97static const char EINA_MAGIC_SHARE_HEAD_STR[] = "Eina Share Head"; 97static const char EINA_MAGIC_SHARE_HEAD_STR[] = "Eina Share Head";
98 98
99static int _eina_share_common_count = 0;
99 100
100#define EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(d, unlock, ...) \ 101#define EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(d, unlock, ...) \
101 do { \ 102 do { \
@@ -616,9 +617,12 @@ eina_share_common_init(Eina_Share **_share,
616 const char *node_magic_STR) 617 const char *node_magic_STR)
617{ 618{
618 Eina_Share *share; 619 Eina_Share *share;
620
621 if (_eina_share_common_count++ != 0)
622 return EINA_TRUE;
623
619 share = *_share = calloc(sizeof(Eina_Share), 1); 624 share = *_share = calloc(sizeof(Eina_Share), 1);
620 if (!share) 625 if (!share) goto on_error;
621 return EINA_FALSE;
622 626
623 if (_eina_share_common_log_dom < 0) /*Only register if not already */ 627 if (_eina_share_common_log_dom < 0) /*Only register if not already */
624 _eina_share_common_log_dom = eina_log_domain_register( 628 _eina_share_common_log_dom = eina_log_domain_register(
@@ -628,7 +632,7 @@ eina_share_common_init(Eina_Share **_share,
628 if (_eina_share_common_log_dom < 0) 632 if (_eina_share_common_log_dom < 0)
629 { 633 {
630 EINA_LOG_ERR("Could not register log domain: eina_share_common"); 634 EINA_LOG_ERR("Could not register log domain: eina_share_common");
631 return EINA_FALSE; 635 goto on_error;
632 } 636 }
633 637
634 share->share = calloc(1, sizeof(Eina_Share_Common)); 638 share->share = calloc(1, sizeof(Eina_Share_Common));
@@ -640,7 +644,7 @@ eina_share_common_init(Eina_Share **_share,
640 _eina_share_common_log_dom = -1; 644 _eina_share_common_log_dom = -1;
641 } 645 }
642 646
643 return EINA_FALSE; 647 goto on_error;
644 } 648 }
645 649
646 share->node_magic = node_magic; 650 share->node_magic = node_magic;
@@ -653,6 +657,10 @@ eina_share_common_init(Eina_Share **_share,
653 657
654 _eina_share_common_population_init(share); 658 _eina_share_common_population_init(share);
655 return EINA_TRUE; 659 return EINA_TRUE;
660
661 on_error:
662 _eina_share_common_count--;
663 return EINA_FALSE;
656} 664}
657 665
658/** 666/**
@@ -672,6 +680,9 @@ eina_share_common_shutdown(Eina_Share **_share)
672 unsigned int i; 680 unsigned int i;
673 Eina_Share *share = *_share; 681 Eina_Share *share = *_share;
674 682
683 if (--_eina_share_common_count != 0)
684 return EINA_TRUE;
685
675 SHARE_COMMON_LOCK_BIG(); 686 SHARE_COMMON_LOCK_BIG();
676 687
677 _eina_share_common_population_stats(share); 688 _eina_share_common_population_stats(share);