summaryrefslogtreecommitdiff
path: root/src/lib/efreet
diff options
context:
space:
mode:
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-20 11:55:38 +0200
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-20 11:56:46 +0200
commit0c317eaca288a546124677247952f3962a7117fb (patch)
treee9c08c384d99a017eb66fdbf6b50d3f84d35e469 /src/lib/efreet
parentceb19aaaaa659da98655574b2bbea88288e78555 (diff)
efreet: Make _path_to_file_id threadsafe
Diffstat (limited to 'src/lib/efreet')
-rw-r--r--src/lib/efreet/efreet_utils.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/efreet/efreet_utils.c b/src/lib/efreet/efreet_utils.c
index 87f418b54b..a0bc37c8d8 100644
--- a/src/lib/efreet/efreet_utils.c
+++ b/src/lib/efreet/efreet_utils.c
@@ -25,6 +25,8 @@ static Efreet_Desktop *efreet_util_cache_find(const char *search, const char *wh
25static Eina_List *efreet_util_cache_list(const char *search, const char *what); 25static Eina_List *efreet_util_cache_list(const char *search, const char *what);
26static Eina_List *efreet_util_cache_glob_list(const char *search, const char *what); 26static Eina_List *efreet_util_cache_glob_list(const char *search, const char *what);
27 27
28static Eina_Lock _lock;
29
28static Eina_Hash *file_id_by_desktop_path = NULL; 30static Eina_Hash *file_id_by_desktop_path = NULL;
29 31
30static int init = 0; 32static int init = 0;
@@ -41,9 +43,20 @@ efreet_util_init(void)
41 return 0; 43 return 0;
42 } 44 }
43 45
46 if (!eina_lock_new(&_lock))
47 {
48 ERR("Could not create lock");
49 goto error;
50 }
51
52
44 file_id_by_desktop_path = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del)); 53 file_id_by_desktop_path = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
45 54
46 return init; 55 return init;
56error:
57 eina_log_domain_unregister(_efreet_utils_log_dom);
58 _efreet_utils_log_dom = -1;
59 return 0;
47} 60}
48 61
49int 62int
@@ -51,6 +64,8 @@ efreet_util_shutdown(void)
51{ 64{
52 if (--init) return init; 65 if (--init) return init;
53 66
67 eina_lock_free(&_lock);
68
54 eina_log_domain_unregister(_efreet_utils_log_dom); 69 eina_log_domain_unregister(_efreet_utils_log_dom);
55 _efreet_utils_log_dom = -1; 70 _efreet_utils_log_dom = -1;
56 IF_FREE_HASH(file_id_by_desktop_path); 71 IF_FREE_HASH(file_id_by_desktop_path);
@@ -118,7 +133,9 @@ efreet_util_path_to_file_id(const char *path)
118 } 133 }
119 eina_stringshare_del(base); 134 eina_stringshare_del(base);
120 file_id = eina_stringshare_add(tmp); 135 file_id = eina_stringshare_add(tmp);
121 eina_hash_add(file_id_by_desktop_path, path, (void *)file_id); 136 eina_lock_take(&_lock);
137 eina_hash_set(file_id_by_desktop_path, path, (void *)file_id);
138 eina_lock_release(&_lock);
122 return file_id; 139 return file_id;
123} 140}
124 141