diff options
| author | 2023-02-22 19:15:22 +0100 | |
|---|---|---|
| committer | 2023-02-22 19:15:22 +0100 | |
| commit | 0f328d079c6d6ee8c3fc79359725605c0bffdeb1 (patch) | |
| tree | b6bf17742dcd882bce6277862f5b685c8de074b4 /data.c | |
| parent | Added index locks a bit stronger. (diff) | |
| download | snac2-0f328d079c6d6ee8c3fc79359725605c0bffdeb1.tar.gz snac2-0f328d079c6d6ee8c3fc79359725605c0bffdeb1.tar.xz snac2-0f328d079c6d6ee8c3fc79359725605c0bffdeb1.zip | |
New function index_unlock().
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 12 |
1 files changed, 10 insertions, 2 deletions
| @@ -254,6 +254,14 @@ FILE *index_lock(const char *fn) | |||
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | 256 | ||
| 257 | void 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 | |||
| 257 | int index_add_md5(const char *fn, const char *md5) | 265 | int 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 | } |