summaryrefslogtreecommitdiff
path: root/src/bin/evas/evas_cserve2_shm.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-06-12 15:04:01 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-06-14 17:09:03 +0900
commit16c8ab3b18a6e2ae5fd0065a5ee4c82bd0aced3b (patch)
tree2e9088a0918868bab6dfc2b437a9cce57381dc1b /src/bin/evas/evas_cserve2_shm.c
parent42309042c6e63944cda26e9f7f89cf56d6af3643 (diff)
evas/cserve2: remove garbage shm files during server init
If server crashes or is forcefully killed, it will not properly cleanup its shm files. So, some memory will be leaked pretty badly.
Diffstat (limited to 'src/bin/evas/evas_cserve2_shm.c')
-rw-r--r--src/bin/evas/evas_cserve2_shm.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/bin/evas/evas_cserve2_shm.c b/src/bin/evas/evas_cserve2_shm.c
index 99b7f25066..0c31e17e34 100644
--- a/src/bin/evas/evas_cserve2_shm.c
+++ b/src/bin/evas/evas_cserve2_shm.c
@@ -193,3 +193,41 @@ cserve2_shm_unmap(Shm_Handle *shm)
193 munmap(shm->data, shm->image_size); 193 munmap(shm->data, shm->image_size);
194 shm->data = NULL; 194 shm->data = NULL;
195} 195}
196
197static void
198_cserve2_shm_cleanup()
199{
200 Eina_Iterator *iter;
201 const Eina_File_Direct_Info *f_info;
202 char pattern[NAME_MAX];
203
204 sprintf(pattern, "evas-shm-img-%x-", (int) getuid());
205 iter = eina_file_direct_ls("/dev/shm");
206 EINA_ITERATOR_FOREACH(iter, f_info)
207 {
208 if (strstr(f_info->path, pattern))
209 {
210 const char *shmname = strrchr(f_info->path, '/');
211 if (!shmname) continue;
212
213 if (shm_unlink(shmname) == -1)
214 ERR("Failed to remove shm entry at %s: %d %s", shmname, errno, strerror(errno));
215 else
216 DBG("cserve2 cleanup: removed %s", shmname);
217 }
218 else
219 DBG("cserve2 cleanup: ignoring %s", f_info->path);
220 }
221}
222
223void
224cserve2_shm_init()
225{
226 _cserve2_shm_cleanup();
227}
228
229void
230cserve2_shm_shutdown()
231{
232 _cserve2_shm_cleanup();
233}