summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2016-03-07 13:32:05 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2016-03-07 13:32:05 +0200
commit256180ac167996f6b9a395b010f0bbfae9c345a6 (patch)
treead93d62c082b9173434c24641fd1c0da2935b723
parentda0f8b8cf271ab6aeb0e226636eecd740892888f (diff)
Fix init & shutdown catchers
-rw-r--r--src/lib/cov_preload.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/lib/cov_preload.c b/src/lib/cov_preload.c
index 10cba64..3b5a0b5 100644
--- a/src/lib/cov_preload.c
+++ b/src/lib/cov_preload.c
@@ -9,6 +9,7 @@
9#include "stats_common.h" 9#include "stats_common.h"
10 10
11static int _init_count = 0; 11static int _init_count = 0;
12static Eina_Bool _exit_required = EINA_FALSE;
12 13
13Stat_Infos infos; 14Stat_Infos infos;
14 15
@@ -16,13 +17,14 @@ EAPI int
16evas_init(void) 17evas_init(void)
17{ 18{
18 _init_count++; 19 _init_count++;
19 if (_init_count > 1) return _init_count;
20 int (*foo)() = dlsym(RTLD_NEXT, __func__); 20 int (*foo)() = dlsym(RTLD_NEXT, __func__);
21 infos.l = NULL; 21 if (_init_count == 1)
22 eina_init(); 22 {
23 eet_init(); 23 infos.l = NULL;
24 foo(); 24 eina_init();
25 return _init_count; 25 eet_init();
26 }
27 return foo();
26} 28}
27 29
28EAPI int 30EAPI int
@@ -31,25 +33,28 @@ evas_shutdown()
31 Stat_Info *info; 33 Stat_Info *info;
32 int (*foo)() = dlsym(RTLD_NEXT, __func__); 34 int (*foo)() = dlsym(RTLD_NEXT, __func__);
33 _init_count--; 35 _init_count--;
34 if (_init_count > 1) return _init_count;
35
36 int ret = foo();
37 36
38 stats_save(&infos, "espion_stats.eet", STATS_EET_FORMAT); 37 if (!_init_count && !_exit_required)
39
40 EINA_LIST_FREE(infos.l, info)
41 { 38 {
42 free(info); 39 stats_save(&infos, "espion_stats.eet", STATS_EET_FORMAT);
40
41 EINA_LIST_FREE(infos.l, info)
42 {
43 free(info);
44 }
45 infos.l = NULL;
46 _exit_required = EINA_TRUE;
47 eet_shutdown();
48 eina_shutdown();
43 } 49 }
44 50
45 eet_shutdown(); 51 return foo();
46 eina_shutdown();
47 return ret;
48} 52}
49 53
50static Stat_Info * 54static Stat_Info *
51_info_update(const char *func, Stat_Info *info) 55_info_update(const char *func, Stat_Info *info)
52{ 56{
57 if (_exit_required) return info;
53 if (!info) 58 if (!info)
54 { 59 {
55 info = calloc(1, sizeof(*info)); 60 info = calloc(1, sizeof(*info));