Revision f3ab0d6d src/TopologyManager/cyclon.c

View differences:

src/TopologyManager/cyclon.c
34 34
  
35 35
  struct peer_cache *flying_cache;
36 36
  struct nodeID *dst;
37
  
38
  struct cyclon_proto_context *pc; 
37 39
};
38 40

  
39 41

  
......
110 112
    free(con);
111 113
    return NULL;
112 114
  }
113
  topo_proto_init(myID, metadata, metadata_size);
114
  return con;
115
}
116 115

  
117
static int cyclon_change_metadata(struct peersampler_context *context, void *metadata, int metadata_size)
118
{
119
  if (topo_proto_metadata_update(metadata, metadata_size) <= 0) {
120
    return -1;
116
  con->pc = cyclon_proto_init(myID, metadata, metadata_size);
117
  if (!con->pc){
118
    free(con->local_cache);
119
    free(con);
120
    return NULL;
121 121
  }
122 122

  
123
  return 1;
123
  return con;
124 124
}
125 125

  
126 126
static int cyclon_add_neighbour(struct peersampler_context *context, struct nodeID *neighbour, void *metadata, int metadata_size)
......
132 132
    return -1;
133 133
  }
134 134

  
135
  return cyclon_query(context->flying_cache, neighbour);
135
  return cyclon_query(context->pc, context->flying_cache, neighbour);
136 136
}
137 137

  
138 138
static int cyclon_parse_data(struct peersampler_context *context, const uint8_t *buff, int len)
......
154 154
    remote_cache = entries_undump(buff + sizeof(struct topo_header), len - sizeof(struct topo_header));
155 155
    if (h->type == CYCLON_QUERY) {
156 156
      sent_cache = rand_cache(context->local_cache, context->sent_entries);
157
      cyclon_reply(remote_cache, sent_cache);
157
      cyclon_reply(context->pc, remote_cache, sent_cache);
158 158
      context->dst = NULL;
159 159
    }
160 160
    cache_check(context->local_cache);
......
186 186
    context->dst = nodeid_dup(context->dst);
187 187
    cache_del(context->local_cache, context->dst);
188 188
    context->flying_cache = rand_cache(context->local_cache, context->sent_entries - 1);
189
    cyclon_query(context->flying_cache, context->dst);
189
    cyclon_query(context->pc, context->flying_cache, context->dst);
190 190
  }
191 191
  cache_check(context->local_cache);
192 192

  
......
248 248
  return cache_del(context->local_cache, neighbour);
249 249
}
250 250

  
251
static int cyclon_change_metadata(struct peersampler_context *context, void *metadata, int metadata_size)
252
{
253
  return cyclon_proto_change_metadata(context->pc, metadata, metadata_size);
254
}
255

  
251 256
struct peersampler_iface cyclon = {
252 257
  .init = cyclon_init,
253 258
  .change_metadata = cyclon_change_metadata,

Also available in: Unified diff