summaryrefslogtreecommitdiff
path: root/src/lib/eet
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-04-25 11:59:12 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-04-25 12:00:11 -0400
commita1f649fa9dc1513e90f46eb8f81b6375caebc0c0 (patch)
tree1440662928846f3ad217a9aaef92e0b7fc63b848 /src/lib/eet
parente917be883149fa74d123bccd3ab2ae30307a0dc1 (diff)
eet: add counter for number of frees needed in each directory
Summary: further optimize the eet_shutdown case of closing files and avoid endlessly looping over empty nodes Depends on D5950 Reviewers: cedric Reviewed By: cedric Differential Revision: https://phab.enlightenment.org/D5951
Diffstat (limited to 'src/lib/eet')
-rw-r--r--src/lib/eet/Eet_private.h1
-rw-r--r--src/lib/eet/eet_lib.c35
2 files changed, 29 insertions, 7 deletions
diff --git a/src/lib/eet/Eet_private.h b/src/lib/eet/Eet_private.h
index c2e6702cac..ca552277c1 100644
--- a/src/lib/eet/Eet_private.h
+++ b/src/lib/eet/Eet_private.h
@@ -110,6 +110,7 @@ struct _Eet_File_Directory
110{ 110{
111 int size; 111 int size;
112 Eet_File_Node **nodes; 112 Eet_File_Node **nodes;
113 unsigned int free_count;
113}; 114};
114 115
115struct _Eet_File_Node 116struct _Eet_File_Node
diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index 7428ffcac5..e53d1ed89a 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -885,7 +885,10 @@ eet_internal_read2(Eet_File *ef)
885 { 885 {
886 efn->data = malloc(efn->size); 886 efn->data = malloc(efn->size);
887 if (efn->data) 887 if (efn->data)
888 memcpy(efn->data, ef->data + efn->offset, efn->size); 888 {
889 memcpy(efn->data, ef->data + efn->offset, efn->size);
890 ef->header->directory->free_count++;
891 }
889 } 892 }
890 893
891 /* compute the possible position of a signature */ 894 /* compute the possible position of a signature */
@@ -1189,6 +1192,7 @@ eet_internal_read1(Eet_File *ef)
1189 1192
1190 strncpy(efn->name, (char *)p + HEADER_SIZE, name_size); 1193 strncpy(efn->name, (char *)p + HEADER_SIZE, name_size);
1191 efn->name[name_size] = 0; 1194 efn->name[name_size] = 0;
1195 ef->header->directory->free_count++;
1192 1196
1193 WRN( 1197 WRN(
1194 "File: %s is not up to date for key \"%s\" - needs rebuilding sometime", 1198 "File: %s is not up to date for key \"%s\" - needs rebuilding sometime",
@@ -1211,7 +1215,10 @@ eet_internal_read1(Eet_File *ef)
1211 { 1215 {
1212 data = malloc(efn->size); 1216 data = malloc(efn->size);
1213 if (data) 1217 if (data)
1214 memcpy(data, ef->data + efn->offset, efn->size); 1218 {
1219 memcpy(data, ef->data + efn->offset, efn->size);
1220 ef->header->directory->free_count++;
1221 }
1215 1222
1216 efn->data = data; 1223 efn->data = data;
1217 } 1224 }
@@ -1320,21 +1327,31 @@ eet_internal_close(Eet_File *ef,
1320 int i, num; 1327 int i, num;
1321 1328
1322 num = (1 << ef->header->directory->size); 1329 num = (1 << ef->header->directory->size);
1323 for (i = 0; i < num; i++) 1330 for (i = 0; i < num && ef->header->directory->free_count; i++)
1324 { 1331 {
1325 Eet_File_Node *efn; 1332 Eet_File_Node *efn;
1326 1333
1327 while ((efn = ef->header->directory->nodes[i])) 1334 while ((efn = ef->header->directory->nodes[i]))
1328 { 1335 {
1329 if (efn->data) 1336 if (efn->data)
1330 free(efn->data); 1337 {
1338 free(efn->data);
1339 ef->header->directory->free_count--;
1340 }
1331 1341
1332 ef->header->directory->nodes[i] = efn->next; 1342 ef->header->directory->nodes[i] = efn->next;
1333 1343
1334 if (efn->free_name) 1344 if (efn->free_name)
1335 free(efn->name); 1345 {
1336 1346 free(efn->name);
1337 if (!shutdown) 1347 ef->header->directory->free_count--;
1348 }
1349
1350 if (shutdown)
1351 {
1352 if (!ef->header->directory->free_count) break;
1353 }
1354 else
1338 eet_file_node_mp_free(efn); 1355 eet_file_node_mp_free(efn);
1339 } 1356 }
1340 } 1357 }
@@ -2310,12 +2327,14 @@ eet_alias(Eet_File *ef,
2310 efn->name = strdup(name); 2327 efn->name = strdup(name);
2311 efn->name_size = strlen(efn->name) + 1; 2328 efn->name_size = strlen(efn->name) + 1;
2312 efn->free_name = 1; 2329 efn->free_name = 1;
2330 ef->header->directory->free_count++;
2313 efn->data = NULL; 2331 efn->data = NULL;
2314 2332
2315 efn->next = ef->header->directory->nodes[hash]; 2333 efn->next = ef->header->directory->nodes[hash];
2316 ef->header->directory->nodes[hash] = efn; 2334 ef->header->directory->nodes[hash] = efn;
2317 2335
2318 eet_define_data(ef, efn, in, strlen(destination) + 1, comp, 0); 2336 eet_define_data(ef, efn, in, strlen(destination) + 1, comp, 0);
2337 ef->header->directory->free_count++;
2319 } 2338 }
2320 2339
2321 efn->alias = 1; 2340 efn->alias = 1;
@@ -2458,12 +2477,14 @@ eet_write_cipher(Eet_File *ef,
2458 efn->name = strdup(name); 2477 efn->name = strdup(name);
2459 efn->name_size = strlen(efn->name) + 1; 2478 efn->name_size = strlen(efn->name) + 1;
2460 efn->free_name = 1; 2479 efn->free_name = 1;
2480 ef->header->directory->free_count++;
2461 efn->data = NULL; 2481 efn->data = NULL;
2462 2482
2463 efn->next = ef->header->directory->nodes[hash]; 2483 efn->next = ef->header->directory->nodes[hash];
2464 ef->header->directory->nodes[hash] = efn; 2484 ef->header->directory->nodes[hash] = efn;
2465 2485
2466 eet_define_data(ef, efn, in, size, comp, !!cipher_key); 2486 eet_define_data(ef, efn, in, size, comp, !!cipher_key);
2487 ef->header->directory->free_count++;
2467 } 2488 }
2468 2489
2469 /* flags that writes are pending */ 2490 /* flags that writes are pending */