Revision 0e858c17

View differences:

loop-mt.c
4 4
#include <stdlib.h>
5 5
#include <stdio.h>
6 6
#include <pthread.h>
7

  
8 7
#include <net_helper.h>
9
#include <topmanager.h>
10 8
#include <msg_types.h>
9
#include <peerset.h>
10
#include <peer.h>
11 11

  
12
#include "chunk_signaling.h"
12 13
#include "streaming.h"
14
#include "topology.h"
13 15
#include "loop.h"
14 16

  
15 17
#define BUFFSIZE 64 * 1024
......
19 21
static pthread_mutex_t cb_mutex;
20 22
static pthread_mutex_t topology_mutex;
21 23
static struct nodeID *s;
24
static struct peerset *pset;
22 25

  
23 26
static void *chunk_forging(void *dummy)
24 27
{
......
45 48
    switch (buff[0] /* Message Type */) {
46 49
      case MSG_TYPE_TOPOLOGY:
47 50
        pthread_mutex_lock(&topology_mutex);
48
        topParseData(buff, len);
51
        update_peers(pset, buff, len);
49 52
        pthread_mutex_unlock(&topology_mutex);
50 53
        break;
51 54
      case MSG_TYPE_CHUNK:
......
71 74
    switch (buff[0] /* Message Type */) {
72 75
      case MSG_TYPE_TOPOLOGY:
73 76
        pthread_mutex_lock(&topology_mutex);
74
        topParseData(buff, len);
77
        update_peers(pset, buff, len);
75 78
        pthread_mutex_unlock(&topology_mutex);
76 79
        break;
77 80
      case MSG_TYPE_CHUNK:
78 81
        pthread_mutex_lock(&cb_mutex);
79
        received_chunk(buff, len);
82
        received_chunk(pset, remote, buff, len);
80 83
        pthread_mutex_unlock(&cb_mutex);
81 84
        break;
85
      case MSG_TYPE_SIGNALLING:
86
        pthread_mutex_lock(&topology_mutex);
87
        sigParseData(buff, len);
88
        pthread_mutex_unlock(&topology_mutex);
89
        break;
82 90
      default:
83 91
        fprintf(stderr, "Unknown Message Type %x\n", buff[0]);
84 92
    }
......
93 101
  int gossiping_period = period * 10;
94 102

  
95 103
  pthread_mutex_lock(&topology_mutex);
96
  topParseData(NULL, 0);
104
  update_peers(pset, NULL, 0);
97 105
  pthread_mutex_unlock(&topology_mutex);
98 106
  while(!done) {
99 107
    pthread_mutex_lock(&topology_mutex);
100
    topParseData(NULL, 0);
108
    update_peers(pset, NULL, 0);
101 109
    pthread_mutex_unlock(&topology_mutex);
102 110
    usleep(gossiping_period);
103 111
  }
......
110 118
  int chunk_period = period / chunks_per_period;
111 119

  
112 120
  while(!done) {
113
    const struct nodeID **neighbours;
114
    int n;
115

  
116 121
    pthread_mutex_lock(&topology_mutex);
117
    neighbours = topGetNeighbourhood(&n);
118 122
    pthread_mutex_lock(&cb_mutex);
119
    send_chunk(neighbours, n);
123
    send_chunk(pset);
120 124
    pthread_mutex_unlock(&cb_mutex);
121 125
    pthread_mutex_unlock(&topology_mutex);
122 126
    usleep(chunk_period);
......
132 136
  period = csize;
133 137
  s = s1;
134 138
 
139
  pset = peerset_init(0);
140
  sigInit(s,pset);
135 141
  stream_init(buff_size, s);
136 142
  pthread_mutex_init(&cb_mutex, NULL);
137 143
  pthread_mutex_init(&topology_mutex, NULL);
......
152 158
  chunks_per_period = chunks;
153 159
  s = s1;
154 160
 
161
  pset = peerset_init(0);
162
  sigInit(s,pset);
155 163
  source_init(fname, s);
156 164
  pthread_mutex_init(&cb_mutex, NULL);
157 165
  pthread_mutex_init(&topology_mutex, NULL);

Also available in: Unified diff