summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2023-02-22 19:15:22 +0100
committerGravatar default2023-02-22 19:15:22 +0100
commit0f328d079c6d6ee8c3fc79359725605c0bffdeb1 (patch)
treeb6bf17742dcd882bce6277862f5b685c8de074b4 /data.c
parentAdded index locks a bit stronger. (diff)
downloadsnac2-0f328d079c6d6ee8c3fc79359725605c0bffdeb1.tar.gz
snac2-0f328d079c6d6ee8c3fc79359725605c0bffdeb1.tar.xz
snac2-0f328d079c6d6ee8c3fc79359725605c0bffdeb1.zip
New function index_unlock().
Diffstat (limited to 'data.c')
-rw-r--r--data.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/data.c b/data.c
index 20bf13f..b32461c 100644
--- a/data.c
+++ b/data.c
@@ -254,6 +254,14 @@ FILE *index_lock(const char *fn)
254} 254}
255 255
256 256
257void index_unlock(FILE *f, const char *fn)
258{
259 xs *lck = xs_fmt("%s.lck", fn);
260 unlink(lck);
261 fclose(f);
262}
263
264
257int index_add_md5(const char *fn, const char *md5) 265int index_add_md5(const char *fn, const char *md5)
258/* adds an md5 to an index */ 266/* adds an md5 to an index */
259{ 267{
@@ -275,7 +283,7 @@ int index_add_md5(const char *fn, const char *md5)
275 else 283 else
276 status = 500; 284 status = 500;
277 285
278 fclose(l); 286 index_unlock(l, fn);
279 287
280 return status; 288 return status;
281} 289}
@@ -327,7 +335,7 @@ int index_del_md5(const char *fn, const char *md5)
327 else 335 else
328 status = 500; 336 status = 500;
329 337
330 fclose(l); 338 index_unlock(l, fn);
331 339
332 return status; 340 return status;
333} 341}