streamers / chunklock.c @ abd2ef3b
History | View | Annotate | Download (573 Bytes)
1 |
/*
|
---|---|
2 |
* Copyright (c) 2010 Luca Abeni
|
3 |
* Copyright (c) 2010 Csaba Kiraly
|
4 |
*
|
5 |
* This is free software; see gpl-3.0.txt
|
6 |
*/
|
7 |
#include "chunklock.h" |
8 |
|
9 |
static struct chunkID_set *lock_set; |
10 |
|
11 |
void chunk_lock(int chunkid,struct peer *from){ |
12 |
if (!lock_set) lock_set = chunkID_set_init(16); |
13 |
|
14 |
chunkID_set_add_chunk(lock_set, chunkid); |
15 |
} |
16 |
|
17 |
void chunk_unlock(int chunkid){ |
18 |
if (!lock_set) return; |
19 |
chunkID_set_remove_chunk(lock_set, chunkid); |
20 |
} |
21 |
|
22 |
int chunk_islocked(int chunkid){ |
23 |
int r;
|
24 |
|
25 |
if (!lock_set) return 0; |
26 |
r = chunkID_set_check(lock_set, chunkid); |
27 |
return (r >= 0); |
28 |
} |