Import dht-0.17.
This commit is contained in:
parent
1ef888f9f1
commit
5bb25bbe72
|
@ -1,3 +1,8 @@
|
||||||
|
9 January 2011: dht-0.17:
|
||||||
|
|
||||||
|
* Fix a bug that prevented calling dht_init after dht_uninit.
|
||||||
|
* Remove the "dofree" parameter to dht_uninit.
|
||||||
|
|
||||||
23 December 2010: dht-0.16:
|
23 December 2010: dht-0.16:
|
||||||
|
|
||||||
* Change the interface to allow sharing of the UDP socket e.g. with uTP.
|
* Change the interface to allow sharing of the UDP socket e.g. with uTP.
|
||||||
|
|
|
@ -34,9 +34,7 @@ at client shutdown.
|
||||||
|
|
||||||
* dht_uninit
|
* dht_uninit
|
||||||
|
|
||||||
This may be called at the end of the session. If dofree is true, it frees
|
This may be called at the end of the session.
|
||||||
all the memory allocated for the DHT. If dofree is false, this function
|
|
||||||
currently does nothing.
|
|
||||||
|
|
||||||
Bootstrapping
|
Bootstrapping
|
||||||
*************
|
*************
|
||||||
|
|
|
@ -400,7 +400,7 @@ main(int argc, char **argv)
|
||||||
printf("Found %d (%d + %d) good nodes.\n", i, num, num6);
|
printf("Found %d (%d + %d) good nodes.\n", i, num, num6);
|
||||||
}
|
}
|
||||||
|
|
||||||
dht_uninit(1);
|
dht_uninit();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2009, 2010 by Juliusz Chroboczek
|
Copyright (c) 2009-2011 by Juliusz Chroboczek
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1659,15 +1659,15 @@ dht_init(int s, int s6, const unsigned char *id, const unsigned char *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dht_uninit(int dofree)
|
dht_uninit()
|
||||||
{
|
{
|
||||||
if(dht_socket < 0) {
|
if(dht_socket < 0 && dht_socket6 < 0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dofree)
|
dht_socket = -1;
|
||||||
return 1;
|
dht_socket6 = -1;
|
||||||
|
|
||||||
while(buckets) {
|
while(buckets) {
|
||||||
struct bucket *b = buckets;
|
struct bucket *b = buckets;
|
||||||
|
@ -1680,6 +1680,17 @@ dht_uninit(int dofree)
|
||||||
free(b);
|
free(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(buckets6) {
|
||||||
|
struct bucket *b = buckets6;
|
||||||
|
buckets6 = b->next;
|
||||||
|
while(b->nodes) {
|
||||||
|
struct node *n = b->nodes;
|
||||||
|
b->nodes = n->next;
|
||||||
|
free(n);
|
||||||
|
}
|
||||||
|
free(b);
|
||||||
|
}
|
||||||
|
|
||||||
while(storage) {
|
while(storage) {
|
||||||
struct storage *st = storage;
|
struct storage *st = storage;
|
||||||
storage = storage->next;
|
storage = storage->next;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2009, 2010 by Juliusz Chroboczek
|
Copyright (c) 2009-2011 by Juliusz Chroboczek
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -47,7 +47,7 @@ int dht_nodes(int af,
|
||||||
void dht_dump_tables(FILE *f);
|
void dht_dump_tables(FILE *f);
|
||||||
int dht_get_nodes(struct sockaddr_in *sin, int *num,
|
int dht_get_nodes(struct sockaddr_in *sin, int *num,
|
||||||
struct sockaddr_in6 *sin6, int *num6);
|
struct sockaddr_in6 *sin6, int *num6);
|
||||||
int dht_uninit(int dofree);
|
int dht_uninit(void);
|
||||||
|
|
||||||
/* This must be provided by the user. */
|
/* This must be provided by the user. */
|
||||||
void dht_hash(void *hash_return, int hash_size,
|
void dht_hash(void *hash_return, int hash_size,
|
||||||
|
|
Loading…
Reference in New Issue