Revision 32c9a7bc td.c

View differences:

td.c
13 13
static struct peer *peers;
14 14
static struct chunk *chunks;
15 15
static int num_peers;
16
extern float convergence_precision;
16 17

  
17 18
int comp(int chunk)
18 19
{
......
95 96
struct chunk *td_loop(struct peer *p, int np, int num_chunks, int server_period)
96 97
{
97 98
  int done, t;
99
  struct stats * stat = NULL;
98 100

  
99 101
  chunks = malloc(num_chunks * sizeof(struct chunk));
100 102
  if (chunks == NULL) {
......
103 105
    return NULL;
104 106
  }
105 107
  memset(chunks, 0, num_chunks * sizeof(struct chunk));
108

  
106 109
  num_peers = np;
107 110
  peers = p;
108 111
  ts = server_period;
......
134 137
      }
135 138
    }
136 139
    t++;
140
    if (convergence_precision && chunk_stats_converge(&stat, chunks, num_chunks, peers, num_peers, t - 1))
141
	    done = 1;
137 142
  }
143
  chunk_stats_converge(&stat, chunks, num_chunks, peers, num_peers, t - 1);
144
  chunk_stats_print(stat, CSV_STATS);
145
  if (stat) free(stat);
138 146

  
139 147
  return chunks;
140 148
}

Also available in: Unified diff