Remove needless mutex locks and unlocks

This commit is contained in:
kamkow1
2025-06-28 02:16:42 +02:00
parent 2e70abd0de
commit 48f4a73b0a
4 changed files with 3 additions and 36 deletions

10
main.c
View File

@ -157,7 +157,6 @@ void route_hashtable_put_blogs(Baked_Resource *resource, void *udata)
void init_route_hashtable(void)
{
lockx(&route_hashtable);
shdefault(route_hashtable.value, &route_page_not_found);
shput(route_hashtable.value, clonestr_alloc(&default_allocator, "/"), &route_home);
shput(route_hashtable.value, clonestr_alloc(&default_allocator, "/page-missing"), &route_page_not_found);
@ -167,17 +166,14 @@ void init_route_hashtable(void)
#endif
baked_resource_each(&route_hashtable_put_blogs, nil);
unlockx(&route_hashtable);
}
void free_route_hashtable(void)
{
lockx(&route_hashtable);
for (size_t i = 0; i < shlen(route_hashtable.value); i++) {
free(route_hashtable.value[i].key);
}
shfree(route_hashtable.value);
unlockx(&route_hashtable);
}
char *init_baked_dump(void)
@ -261,9 +257,7 @@ void copy_baked_resources_to_baked_dump(Baked_Resource *resource, void *udata)
void populate_baked_dump(char *baked_dump)
{
lock_baked_resources();
baked_resource_each(&copy_baked_resources_to_baked_dump, baked_dump);
unlock_baked_resources();
}
volatile sig_atomic_t alive = true;
@ -281,12 +275,10 @@ int main(int argc, char ** argv)
start_timer();
init_baked_resources();
lockx(&baked_dump_path);
if ((baked_dump_path.value = init_baked_dump()) == nil) {
return 1;
}
populate_baked_dump(baked_dump_path.value);
unlockx(&baked_dump_path);
mg_log_set(MG_LL_DEBUG);
struct mg_mgr mgr;
@ -304,9 +296,7 @@ int main(int argc, char ** argv)
mg_mgr_free(&mgr);
lockx(&baked_dump_path);
free_baked_dump(baked_dump_path.value);
unlockx(&baked_dump_path);
free_baked_resources();
return 0;