Revision 5f0575fb loop.c

View differences:

loop.c
30 30
#define FDSSIZE 16
31 31
static struct timeval period = {0, 500000};
32 32
static struct timeval tnext;
33
int fixed_offer_threads = 0;
33 34

  
34 35
void tout_init(struct timeval *tv)
35 36
{
......
46 47
  }
47 48
}
48 49

  
49
void loop(struct nodeID *s, int csize, int buff_size)
50
void loop(struct nodeID *s, int polling_time, int buff_size, int offer_threads)
50 51
{
51 52
  int done = 0;
52 53
  static uint8_t buff[BUFFSIZE];
53 54
  int cnt = 0;
54 55
  
55
  period.tv_sec = csize / 1000000;
56
  period.tv_usec = csize % 1000000;
56
  period.tv_sec = polling_time / 1000000;
57
  period.tv_usec = polling_time % 1000000;
57 58
  
58 59
  peers_init();
59 60
  stream_init(buff_size, s);
60 61
  update_peers(NULL, NULL, 0);
62
  
63
  	fixed_offer_threads = offer_threads;
64
   
65
   // Start all offer threads once forever
66
   send_offer();
67
  
61 68
  while (!done) {
62 69
    int len, res;
63 70
    struct timeval tv;
......
176 183
        for (i = 0; i < chunks; i++) {	// @TODO: why this cycle?
177 184
          send_chunk();
178 185
        }
179
        send_offer();
180 186
        if (cnt++ % 10 == 0) {
181 187
            update_peers(NULL, NULL, 0);
182 188
        }
......
186 192
    }
187 193
  }
188 194
}
195

  
196
int get_fixed_offer_threads(void) {
197
	return fixed_offer_threads;
198
	}

Also available in: Unified diff