Revision 2dab7813

View differences:

topology.c
174 174
  return send_to_peer(me, dst, msg, 2);
175 175
}
176 176

  
177
static void add_peer_silent(const struct nodeID *id, const struct metadata *m)
177
static void add_peer(const struct nodeID *id, const struct metadata *m, bool local, bool remote)
178 178
{
179
  if (local) {
179 180
      dprintf("Adding %s to neighbourhood! cb_size:%d\n", node_addr(id), m?m->cb_size:-1);
180 181
      peerset_add_peer(pset, id);
181 182
      if (m) peerset_get_peer(pset, id)->cb_size = m->cb_size;
......
183 184
      /* add measures here */
184 185
      add_measures(id);
185 186
      send_bmap(id);
186
}
187

  
188
static void add_peer(const struct nodeID *id, const struct metadata *m)
189
{
190
      add_peer_silent(id, m);
187
  }
188
  if (remote) {
191 189
      dtprintf("Topo: explicit topo message sent!!! to %s (peers:%d)\n", node_addr(id));
192 190
      send_topo_msg(id, STREAMER_TOPOLOGY_MSG_ADD);
191
  }
193 192
}
194 193

  
195
static void remove_peer_silent(const struct nodeID *id)
194
static void remove_peer(const struct nodeID *id, bool local, bool remote)
196 195
{
196
  if (local) {
197 197
      dprintf("Removing %s from neighbourhood!\n", node_addr(id));
198 198
      /* add measures here */
199 199
      delete_measures(id);
200 200
      peerset_remove_peer(pset, id);
201
}
202

  
203
static void remove_peer(const struct nodeID *id)
204
{
205
      remove_peer_silent(id);
201
  }
202
  if (remote) {
206 203
      dtprintf("Topo: explicit topo message sent!!! to %s (peers:%d)\n", node_addr(id));
207 204
      send_topo_msg(id, STREAMER_TOPOLOGY_MSG_REMOVE);
205
  }
208 206
}
209 207

  
210 208
//get the rtt. Currenly only MONL version is supported
......
263 261
        ftprintf(stderr,"Topo: dropping inactive %s (peers:%d)\n", node_addr(peers[i].id), peerset_size(pset));
264 262
        //if (peerset_size(pset) > 1) {	// avoid dropping our last link to the world
265 263
        topoAddToBL(peers[i].id);
266
        remove_peer(peers[i--].id);
264
        remove_peer(peers[i--].id, true, true);
267 265
        //}
268 266
      }
269 267
    }
......
286 284
    switch (buff[1]) {
287 285
      case STREAMER_TOPOLOGY_MSG_ADD:
288 286
        ftprintf(stderr,"Topo: adding for symmetry %s (peers:%d)\n", node_addr(from), peerset_size(pset));
289
        add_peer_silent(from, NULL);
287
        add_peer(from, NULL, true, false);
290 288
        break;
291 289
      case STREAMER_TOPOLOGY_MSG_REMOVE:
292 290
        ftprintf(stderr,"Topo: removing for symmetry %s (peers:%d)\n", node_addr(from), peerset_size(pset));
293
        remove_peer_silent(from);
291
        remove_peer(from, true, false);
294 292
        break;
295 293
      default:
296 294
        fprintf(stderr, "Bad streamer topo message received!\n");
......
358 356
      //searching for the metadata
359 357
      if (nidset_find(&j, newids, newids_size, toadds[i])) {
360 358
        fprintf(stderr," adding %s\n", node_addr(toadds[i]));
361
        add_peer(newids[j], &metas[j]);
359
        add_peer(newids[j], &metas[j], true, true);
362 360
      } else {
363 361
        fprintf(stderr," Error: missing metadata for %s\n", node_addr(toadds[i]));
364 362
      }
......
369 367
    nidset_complement(toremoves, &toremoves_size, oldids, oldids_size, selecteds, selecteds_size);
370 368
    for (i = 0; i < toremoves_size; i++) {
371 369
      fprintf(stderr," removing %s\n", node_addr(toremoves[i]));
372
      remove_peer(toremoves[i]);
370
      remove_peer(toremoves[i], true, true);
373 371
    }
374 372
    fprintf(stderr,"Topo remove end\n");
375 373
  }
......
383 381
  if (!p) {
384 382
    //fprintf(stderr,"warning: received message from unknown peer: %s!%s\n",node_addr(id), reg ? " Adding it to pset." : "");
385 383
    if (reg) {
386
      add_peer(id,NULL);
384
      add_peer(id,NULL, true, false);
387 385
      fprintf(stderr,"Topo: ext adding %s (peers:%d)\n", node_addr(id), peerset_size(pset));
388 386
      p = peerset_get_peer(pset,id);
389 387
    }

Also available in: Unified diff