Revision f08e1d8c

View differences:

src/PeerSampler/ncast.c
11 11
#include <stdio.h>
12 12
#include <stdbool.h>
13 13
#include <string.h>
14
#include <limits.h>
14 15

  
15 16
#include "net_helper.h"
16 17
#include "peersampler_iface.h"
......
37 38
  int counter;
38 39
  struct ncast_proto_context *tc;
39 40
  const struct nodeID **r;
41
  int query_tokens;
40 42
};
41 43

  
42 44
static uint64_t gettime(void)
......
121 123
    return NULL;
122 124
  }
123 125

  
126
  context->query_tokens = 0;
127

  
124 128
  return context;
125 129
}
126 130

  
......
161 165
    remote_cache = entries_undump(buff + sizeof(struct topo_header), len - sizeof(struct topo_header));
162 166
    if (h->type == NCAST_QUERY) {
163 167
      ncast_reply(context->tc, remote_cache, context->local_cache);
168
    } else {
169
     context->query_tokens--;	//a query was successful
164 170
    }
165 171
    new = merge_caches(context->local_cache, remote_cache, context->cache_size, &dummy);
166 172
    cache_free(remote_cache);
......
171 177
  }
172 178

  
173 179
  if (time_to_send(context)) {
180
    int ret = INT_MIN;
181
    int i;
182

  
183
    context->query_tokens++;
184

  
174 185
    cache_update(context->local_cache);
175
    return ncast_query(context->tc, context->local_cache);
176
  }
186
    for (i = 0; i < context->query_tokens; i++) {
187
      int r;
177 188

  
189
      r = ncast_query(context->tc, context->local_cache);
190
      r = r > ret ? r : ret;
191
    }
192
  }
178 193
  return 0;
179 194
}
180 195

  

Also available in: Unified diff