mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
Import dht-0.17.
This commit is contained in:
parent
1ef888f9f1
commit
5bb25bbe72
5 changed files with 25 additions and 11 deletions
5
third-party/dht/CHANGES
vendored
5
third-party/dht/CHANGES
vendored
|
@ -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:
|
||||
|
||||
* Change the interface to allow sharing of the UDP socket e.g. with uTP.
|
||||
|
|
4
third-party/dht/README
vendored
4
third-party/dht/README
vendored
|
@ -34,9 +34,7 @@ at client shutdown.
|
|||
|
||||
* dht_uninit
|
||||
|
||||
This may be called at the end of the session. If dofree is true, it frees
|
||||
all the memory allocated for the DHT. If dofree is false, this function
|
||||
currently does nothing.
|
||||
This may be called at the end of the session.
|
||||
|
||||
Bootstrapping
|
||||
*************
|
||||
|
|
2
third-party/dht/dht-example.c
vendored
2
third-party/dht/dht-example.c
vendored
|
@ -400,7 +400,7 @@ main(int argc, char **argv)
|
|||
printf("Found %d (%d + %d) good nodes.\n", i, num, num6);
|
||||
}
|
||||
|
||||
dht_uninit(1);
|
||||
dht_uninit();
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
|
|
21
third-party/dht/dht.c
vendored
21
third-party/dht/dht.c
vendored
|
@ -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
|
||||
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
|
||||
dht_uninit(int dofree)
|
||||
dht_uninit()
|
||||
{
|
||||
if(dht_socket < 0) {
|
||||
if(dht_socket < 0 && dht_socket6 < 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!dofree)
|
||||
return 1;
|
||||
dht_socket = -1;
|
||||
dht_socket6 = -1;
|
||||
|
||||
while(buckets) {
|
||||
struct bucket *b = buckets;
|
||||
|
@ -1680,6 +1680,17 @@ dht_uninit(int dofree)
|
|||
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) {
|
||||
struct storage *st = storage;
|
||||
storage = storage->next;
|
||||
|
|
4
third-party/dht/dht.h
vendored
4
third-party/dht/dht.h
vendored
|
@ -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
|
||||
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);
|
||||
int dht_get_nodes(struct sockaddr_in *sin, int *num,
|
||||
struct sockaddr_in6 *sin6, int *num6);
|
||||
int dht_uninit(int dofree);
|
||||
int dht_uninit(void);
|
||||
|
||||
/* This must be provided by the user. */
|
||||
void dht_hash(void *hash_return, int hash_size,
|
||||
|
|
Loading…
Reference in a new issue