Revision 67700aad

View differences:

include/peerset.h
20 20
void peerset_destroy(struct peerset **h);
21 21

  
22 22
#define peerset_for_each(pset,p,i) \
23
		for(i=0,p= peerset_size(pset) > 0 ? ((const struct peer*)peerset_get_peers(pset)[0]) : NULL; i<peerset_size(pset);i++,p=((const struct peer*)peerset_get_peers(pset)[i]))
23
		for(i=0,p= peerset_size(pset) > 0 ? ((struct peer const *)peerset_get_peers(pset)[0]) : NULL; i<peerset_size(pset);i++,p=((struct peer const *)peerset_get_peers(pset)[i]))
24 24

  
25 25
 /**
26 26
  * @brief Allocate a  peer set.
src/PeerSet/peerset_ops.c
6 6
 */
7 7

  
8 8
#include <stdlib.h>
9
#include <stdio.h>
9 10
#include <stdint.h>
10 11
#include <string.h>
11 12
#include <limits.h>
......
23 24
{
24 25
  const struct peer *peer = *(struct peer *const *)p;
25 26

  
26
  return nodeid_cmp( (const struct nodeID *) id, peer->id);
27
  if(id && p)
28
    return nodeid_cmp( (const struct nodeID *) id, peer->id);
29
  else
30
  {
31
    //fprintf(stderr,"[DEBUG] wrong peer or id\n");
32
    return 0;
33
  }
27 34
}
28 35

  
29 36
static int peerset_check_insert_pos(const struct peerset *h, const struct nodeID *id)
src/net_helper-udp.c
313 313
	char ip1[80], ip2[80];
314 314
	int port1,port2,res;
315 315

  
316
	port1=node_port(s1);
317
	port2=node_port(s2);
318
	node_ip(s1,ip1,80);
319
	node_ip(s2,ip2,80);
320

  
321
//	int res = (port1^port2)|strcmp(ip1,ip2);
322
//	fprintf(stderr,"Comparing %s:%d and %s:%d\n",ip1,port1,ip2,port2);
323
//	fprintf(stderr,"Result: %d\n",res);
324
	res  = strcmp(ip1,ip2);
325
	if (res!=0)
326
		return res;
327
	else
328
		return port1-port2;
329
//		return port1 == port2 ? 0 : 1;
330

  
331
//  return memcmp(&s1->addr, &s2->addr, sizeof(struct sockaddr_storage));
316
  if(s1 && s2)
317
  {
318
    port1=node_port(s1);
319
    port2=node_port(s2);
320
    node_ip(s1,ip1,80);
321
    node_ip(s2,ip2,80);
322

  
323
  //	int res = (port1^port2)|strcmp(ip1,ip2);
324
  //	fprintf(stderr,"Comparing %s:%d and %s:%d\n",ip1,port1,ip2,port2);
325
  //	fprintf(stderr,"Result: %d\n",res);
326
    res  = strcmp(ip1,ip2);
327
    if (res!=0)
328
      return res;
329
    else
330
      return port1-port2;
331
  //		return port1 == port2 ? 0 : 1;
332

  
333
  //  return memcmp(&s1->addr, &s2->addr, sizeof(struct sockaddr_storage));
334
  }
335
  else
336
    return 0;
332 337
}
333 338

  
334 339
int nodeid_dump(uint8_t *b, const struct nodeID *s, size_t max_write_size)

Also available in: Unified diff