summaryrefslogtreecommitdiff
path: root/src/lib/eet
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-04-16 18:48:05 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-04-25 12:00:11 -0400
commite917be883149fa74d123bccd3ab2ae30307a0dc1 (patch)
tree50d3f63cf9c87415f8ce24a1f19f6ec287023d65 /src/lib/eet
parente28c76e2444646d9aa9edb344f3033dbc54eb50d (diff)
eet: simplify shutdown file closing
no need to free mempool memory when the mempool is about to be freed, and eet_clearcache duplicates existing shutdown functionality Differential Revision: https://phab.enlightenment.org/D5950
Diffstat (limited to 'src/lib/eet')
-rw-r--r--src/lib/eet/eet_lib.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index 58841e56f7..7428ffcac5 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -93,8 +93,7 @@ read_binbuf_from_disk(Eet_File *ef,
93 Eet_File_Node *efn); 93 Eet_File_Node *efn);
94 94
95static Eet_Error 95static Eet_Error
96eet_internal_close(Eet_File *ef, 96eet_internal_close(Eet_File *ef, Eina_Bool locked, Eina_Bool shutdown);
97 Eina_Bool locked);
98 97
99static Eina_Lock eet_cache_lock; 98static Eina_Lock eet_cache_lock;
100 99
@@ -147,7 +146,7 @@ eet_test_close(int test,
147 if (test) 146 if (test)
148 { 147 {
149 ef->delete_me_now = 1; 148 ef->delete_me_now = 1;
150 eet_internal_close(ef, EINA_TRUE); 149 eet_internal_close(ef, EINA_TRUE, EINA_FALSE);
151 } 150 }
152 151
153 return test; 152 return test;
@@ -205,7 +204,7 @@ eet_cache_add(Eet_File *ef,
205 if (del_ef) 204 if (del_ef)
206 { 205 {
207 del_ef->delete_me_now = 1; 206 del_ef->delete_me_now = 1;
208 eet_internal_close(del_ef, EINA_TRUE); 207 eet_internal_close(del_ef, EINA_TRUE, EINA_FALSE);
209 } 208 }
210 } 209 }
211 210
@@ -643,7 +642,7 @@ eet_shutdown(void)
643 for (i = 0; i < num; i++) 642 for (i = 0; i < num; i++)
644 { 643 {
645 ERR("File '%s' is still open %i times !", closelist[i]->path, closelist[i]->references); 644 ERR("File '%s' is still open %i times !", closelist[i]->path, closelist[i]->references);
646 eet_internal_close(closelist[i], EINA_TRUE); 645 eet_internal_close(closelist[i], EINA_TRUE, EINA_TRUE);
647 } 646 }
648 } 647 }
649 eet_node_shutdown(); 648 eet_node_shutdown();
@@ -734,7 +733,7 @@ eet_clearcache(void)
734 733
735 for (i = 0; i < num; i++) 734 for (i = 0; i < num; i++)
736 { 735 {
737 eet_internal_close(closelist[i], EINA_TRUE); 736 eet_internal_close(closelist[i], EINA_TRUE, EINA_FALSE);
738 } 737 }
739 } 738 }
740 739
@@ -1254,7 +1253,7 @@ eet_internal_read(Eet_File *ef)
1254 1253
1255 default: 1254 default:
1256 ef->delete_me_now = 1; 1255 ef->delete_me_now = 1;
1257 eet_internal_close(ef, EINA_TRUE); 1256 eet_internal_close(ef, EINA_TRUE, EINA_FALSE);
1258 break; 1257 break;
1259 } 1258 }
1260 1259
@@ -1263,7 +1262,7 @@ eet_internal_read(Eet_File *ef)
1263 1262
1264static Eet_Error 1263static Eet_Error
1265eet_internal_close(Eet_File *ef, 1264eet_internal_close(Eet_File *ef,
1266 Eina_Bool locked) 1265 Eina_Bool locked, Eina_Bool shutdown)
1267{ 1266{
1268 Eet_Error err = EET_ERROR_NONE; 1267 Eet_Error err = EET_ERROR_NONE;
1269 1268
@@ -1335,16 +1334,19 @@ eet_internal_close(Eet_File *ef,
1335 if (efn->free_name) 1334 if (efn->free_name)
1336 free(efn->name); 1335 free(efn->name);
1337 1336
1338 eet_file_node_mp_free(efn); 1337 if (!shutdown)
1338 eet_file_node_mp_free(efn);
1339 } 1339 }
1340 } 1340 }
1341 free(ef->header->directory->nodes); 1341 free(ef->header->directory->nodes);
1342 } 1342 }
1343 1343
1344 eet_file_directory_mp_free(ef->header->directory); 1344 if (!shutdown)
1345 eet_file_directory_mp_free(ef->header->directory);
1345 } 1346 }
1346 1347
1347 eet_file_header_mp_free(ef->header); 1348 if (!shutdown)
1349 eet_file_header_mp_free(ef->header);
1348 } 1350 }
1349 1351
1350 eet_dictionary_free(ef->ed); 1352 eet_dictionary_free(ef->ed);
@@ -1365,7 +1367,8 @@ eet_internal_close(Eet_File *ef,
1365 1367
1366 /* free it */ 1368 /* free it */
1367 eina_stringshare_del(ef->path); 1369 eina_stringshare_del(ef->path);
1368 eet_file_mp_free(ef); 1370 if (!shutdown)
1371 eet_file_mp_free(ef);
1369 return err; 1372 return err;
1370 1373
1371on_error: 1374on_error:
@@ -1434,7 +1437,7 @@ eet_mmap(const Eina_File *file)
1434 eet_sync(ef); 1437 eet_sync(ef);
1435 ef->references++; 1438 ef->references++;
1436 ef->delete_me_now = 1; 1439 ef->delete_me_now = 1;
1437 eet_internal_close(ef, EINA_TRUE); 1440 eet_internal_close(ef, EINA_TRUE, EINA_FALSE);
1438 } 1441 }
1439 1442
1440 ef = eet_cache_find(path, eet_readers, eet_readers_num); 1443 ef = eet_cache_find(path, eet_readers, eet_readers_num);
@@ -1510,7 +1513,7 @@ eet_open(const char *file,
1510 eet_sync(ef); 1513 eet_sync(ef);
1511 ef->references++; 1514 ef->references++;
1512 ef->delete_me_now = 1; 1515 ef->delete_me_now = 1;
1513 eet_internal_close(ef, EINA_TRUE); 1516 eet_internal_close(ef, EINA_TRUE, EINA_FALSE);
1514 } 1517 }
1515 1518
1516 ef = eet_cache_find((char *)file, eet_readers, eet_readers_num); 1519 ef = eet_cache_find((char *)file, eet_readers, eet_readers_num);
@@ -1523,7 +1526,7 @@ eet_open(const char *file,
1523 { 1526 {
1524 ef->delete_me_now = 1; 1527 ef->delete_me_now = 1;
1525 ef->references++; 1528 ef->references++;
1526 eet_internal_close(ef, EINA_TRUE); 1529 eet_internal_close(ef, EINA_TRUE, EINA_FALSE);
1527 } 1530 }
1528 1531
1529 ef = eet_cache_find((char *)file, eet_writers, eet_writers_num); 1532 ef = eet_cache_find((char *)file, eet_writers, eet_writers_num);
@@ -1574,7 +1577,7 @@ open_error:
1574 { 1577 {
1575 ef->delete_me_now = 1; 1578 ef->delete_me_now = 1;
1576 ef->references++; 1579 ef->references++;
1577 eet_internal_close(ef, EINA_TRUE); 1580 eet_internal_close(ef, EINA_TRUE, EINA_FALSE);
1578 ef = NULL; 1581 ef = NULL;
1579 } 1582 }
1580 1583
@@ -1890,7 +1893,7 @@ eet_identity_set(Eet_File *ef,
1890EAPI Eet_Error 1893EAPI Eet_Error
1891eet_close(Eet_File *ef) 1894eet_close(Eet_File *ef)
1892{ 1895{
1893 return eet_internal_close(ef, EINA_FALSE); 1896 return eet_internal_close(ef, EINA_FALSE, EINA_FALSE);
1894} 1897}
1895 1898
1896EAPI void * 1899EAPI void *