Revision abd2ef3b

View differences:

Makefile
26 26
LDFLAGS = -L$(GRAPES)/som/TopologyManager -L$(GRAPES)/som/ChunkTrading -L$(GRAPES)/som/ChunkBuffer -L$(GRAPES)/som/Scheduler -L$(GRAPES)/som/PeerSet -L$(GRAPES)/som/ChunkIDSet
27 27
LDLIBS = -ltrading -lcb -ltopman -lsched -lpeerset -lsignalling
28 28

  
29
OBJS = dumbstreamer.o streaming.o topology.o output.o net_helpers.o input.o chunk_signaling.o out-stream.o
29
OBJS = dumbstreamer.o streaming.o topology.o output.o net_helpers.o input.o chunk_signaling.o out-stream.o chunklock.o
30 30
ifdef THREADS
31 31
OBJS += loop-mt.o
32 32
CFLAGS += -pthread
chunklock.c
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
}
chunklock.h
1
#ifndef CHUNKLOCK_H
2
#define CHUNKLOCK_H
3

  
4
#include <peer.h>
5

  
6
void chunk_lock(int chunkid,struct peer *from);
7
void chunk_unlock(int chunkid);
8
int chunk_islocked(int chunkid);
9

  
10
#endif //CHUNKLOCK_H
streaming.c
16 16
#include "input.h"
17 17
#include "dbg.h"
18 18
#include "chunk_signaling.h"
19
#include "chunklock.h"
19 20

  
20 21
#include "scheduler_la.h"
21 22

  
......
23 24
static struct input_desc *input;
24 25
static int cb_size;
25 26
static int transid=0;
26
struct chunkID_set *lock_set;
27 27

  
28 28
int _needs(struct chunkID_set *cset, int cb_size, int cid);
29 29

  
30
void chunk_lock(int chunkid,struct peer *from){
31
  if (!lock_set) lock_set = chunkID_set_init(16);
32

  
33
  chunkID_set_add_chunk(lock_set, chunkid);
34
}
35

  
36
void chunk_unlock(int chunkid){
37
  if (!lock_set) return;
38
  chunkID_set_remove_chunk(lock_set, chunkid);
39
}
40

  
41
int chunk_islocked(int chunkid){
42
  int r;
43

  
44
  if (!lock_set) return 0;
45
  r = chunkID_set_check(lock_set, chunkid);
46
  return (r >= 0);
47
}
48

  
49 30
void stream_init(int size, struct nodeID *myID)
50 31
{
51 32
  char conf[32];

Also available in: Unified diff