mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Renamed list functions to fix conflict issue on certain machines.
This commit is contained in:
parent
ac5e44debb
commit
7adefb6e6b
@ -99,7 +99,7 @@ static int realloc_connection(TCP_Server *TCP_server, uint32_t num)
|
||||
*/
|
||||
static int get_TCP_connection_index(TCP_Server *TCP_server, uint8_t *public_key)
|
||||
{
|
||||
return list_find(&TCP_server->accepted_key_list, public_key);
|
||||
return bs_list_find(&TCP_server->accepted_key_list, public_key);
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ static int add_accepted(TCP_Server *TCP_server, TCP_Secure_Connection *con)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!list_add(&TCP_server->accepted_key_list, con->public_key, index))
|
||||
if (!bs_list_add(&TCP_server->accepted_key_list, con->public_key, index))
|
||||
return -1;
|
||||
|
||||
memcpy(&TCP_server->accepted_connection_array[index], con, sizeof(TCP_Secure_Connection));
|
||||
@ -166,7 +166,7 @@ static int del_accepted(TCP_Server *TCP_server, int index)
|
||||
if (TCP_server->accepted_connection_array[index].status == TCP_STATUS_NO_STATUS)
|
||||
return -1;
|
||||
|
||||
if (!list_remove(&TCP_server->accepted_key_list, TCP_server->accepted_connection_array[index].public_key, index))
|
||||
if (!bs_list_remove(&TCP_server->accepted_key_list, TCP_server->accepted_connection_array[index].public_key, index))
|
||||
return -1;
|
||||
|
||||
memset(&TCP_server->accepted_connection_array[index], 0, sizeof(TCP_Secure_Connection));
|
||||
@ -914,7 +914,7 @@ TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, uint16_t
|
||||
memcpy(temp->public_key, public_key, crypto_box_PUBLICKEYBYTES);
|
||||
memcpy(temp->secret_key, secret_key, crypto_box_SECRETKEYBYTES);
|
||||
|
||||
list_init(&temp->accepted_key_list, crypto_box_PUBLICKEYBYTES);
|
||||
bs_list_init(&temp->accepted_key_list, crypto_box_PUBLICKEYBYTES);
|
||||
|
||||
return temp;
|
||||
}
|
||||
@ -1229,7 +1229,7 @@ void kill_TCP_server(TCP_Server *TCP_server)
|
||||
set_callback_handle_recv_1(TCP_server->onion, NULL, NULL);
|
||||
}
|
||||
|
||||
list_free(&TCP_server->accepted_key_list);
|
||||
bs_list_free(&TCP_server->accepted_key_list);
|
||||
|
||||
#ifdef TCP_SERVER_USE_EPOLL
|
||||
close(TCP_server->efd);
|
||||
|
@ -128,7 +128,7 @@ typedef struct {
|
||||
|
||||
uint64_t counter;
|
||||
|
||||
LIST accepted_key_list;
|
||||
BS_LIST accepted_key_list;
|
||||
} TCP_Server;
|
||||
|
||||
/* Create new TCP server instance.
|
||||
|
@ -45,7 +45,7 @@
|
||||
* < 0 : no match, returns index (return value is INDEX(index)) where
|
||||
* the data should be inserted
|
||||
*/
|
||||
static int find(LIST *list, void *data)
|
||||
static int find(BS_LIST *list, void *data)
|
||||
{
|
||||
//should work well, but could be improved
|
||||
if (list->n == 0) {
|
||||
@ -106,7 +106,7 @@ static int find(LIST *list, void *data)
|
||||
}
|
||||
|
||||
|
||||
void list_init(LIST *list, uint32_t element_size)
|
||||
void bs_list_init(BS_LIST *list, uint32_t element_size)
|
||||
{
|
||||
//set initial values
|
||||
list->n = 0;
|
||||
@ -115,14 +115,14 @@ void list_init(LIST *list, uint32_t element_size)
|
||||
list->ids = NULL;
|
||||
}
|
||||
|
||||
void list_free(LIST *list)
|
||||
void bs_list_free(BS_LIST *list)
|
||||
{
|
||||
//free both arrays
|
||||
free(list->data);
|
||||
free(list->ids);
|
||||
}
|
||||
|
||||
int list_find(LIST *list, void *data)
|
||||
int bs_list_find(BS_LIST *list, void *data)
|
||||
{
|
||||
int r = find(list, data);
|
||||
|
||||
@ -134,7 +134,7 @@ int list_find(LIST *list, void *data)
|
||||
return list->ids[r];
|
||||
}
|
||||
|
||||
int list_add(LIST *list, void *data, int id)
|
||||
int bs_list_add(BS_LIST *list, void *data, int id)
|
||||
{
|
||||
//find where the new element should be inserted
|
||||
//see: return value of find()
|
||||
@ -180,7 +180,7 @@ int list_add(LIST *list, void *data, int id)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int list_remove(LIST *list, void *data, int id)
|
||||
int bs_list_remove(BS_LIST *list, void *data, int id)
|
||||
{
|
||||
int i = find(list, data);
|
||||
|
||||
|
@ -35,13 +35,13 @@ typedef struct {
|
||||
uint32_t size; //size of the elements
|
||||
void *data; //array of elements
|
||||
int *ids; //array of element ids
|
||||
} LIST;
|
||||
} BS_LIST;
|
||||
|
||||
/* Initialize a list, element_size is the size of the elements in the list */
|
||||
void list_init(LIST *list, uint32_t element_size);
|
||||
void bs_list_init(BS_LIST *list, uint32_t element_size);
|
||||
|
||||
/* Free a list initiated with list_init */
|
||||
void list_free(LIST *list);
|
||||
void bs_list_free(BS_LIST *list);
|
||||
|
||||
/* Retrieve the id of an element in the list
|
||||
*
|
||||
@ -49,7 +49,7 @@ void list_free(LIST *list);
|
||||
* >= 0 : id associated with data
|
||||
* -1 : failure
|
||||
*/
|
||||
int list_find(LIST *list, void *data);
|
||||
int bs_list_find(BS_LIST *list, void *data);
|
||||
|
||||
/* Add an element with associated id to the list
|
||||
*
|
||||
@ -57,7 +57,7 @@ int list_find(LIST *list, void *data);
|
||||
* 1 : success
|
||||
* 0 : failure (data already in list)
|
||||
*/
|
||||
int list_add(LIST *list, void *data, int id);
|
||||
int bs_list_add(BS_LIST *list, void *data, int id);
|
||||
|
||||
/* Remove element from the list
|
||||
*
|
||||
@ -65,6 +65,6 @@ int list_add(LIST *list, void *data, int id);
|
||||
* 1 : success
|
||||
* 0 : failure (element not found or id does not match
|
||||
*/
|
||||
int list_remove(LIST *list, void *data, int id);
|
||||
int bs_list_remove(BS_LIST *list, void *data, int id);
|
||||
|
||||
#endif
|
||||
|
@ -1329,10 +1329,10 @@ static int crypto_connection_add_source(Net_Crypto *c, int crypt_connection_id,
|
||||
|
||||
if (source.ip.family == AF_INET || source.ip.family == AF_INET6) {
|
||||
if (!ipport_equal(&source, &conn->ip_port)) {
|
||||
if (!list_add(&c->ip_port_list, &source, crypt_connection_id))
|
||||
if (!bs_list_add(&c->ip_port_list, &source, crypt_connection_id))
|
||||
return -1;
|
||||
|
||||
list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);
|
||||
bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);
|
||||
conn->ip_port = source;
|
||||
}
|
||||
|
||||
@ -1609,8 +1609,8 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port)
|
||||
return -1;
|
||||
|
||||
if (!ipport_equal(&ip_port, &conn->ip_port)) {
|
||||
if (list_add(&c->ip_port_list, &ip_port, crypt_connection_id)) {
|
||||
list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);
|
||||
if (bs_list_add(&c->ip_port_list, &ip_port, crypt_connection_id)) {
|
||||
bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);
|
||||
conn->ip_port = ip_port;
|
||||
conn->direct_lastrecv_time = 0;
|
||||
return 0;
|
||||
@ -2103,7 +2103,7 @@ int connection_lossy_data_handler(Net_Crypto *c, int crypt_connection_id,
|
||||
*/
|
||||
static int crypto_id_ip_port(Net_Crypto *c, IP_Port ip_port)
|
||||
{
|
||||
return list_find(&c->ip_port_list, &ip_port);
|
||||
return bs_list_find(&c->ip_port_list, &ip_port);
|
||||
}
|
||||
|
||||
#define CRYPTO_MIN_PACKET_SIZE (1 + sizeof(uint16_t) + crypto_box_MACBYTES)
|
||||
@ -2426,7 +2426,7 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id)
|
||||
|
||||
send_kill_packet(c, crypt_connection_id);
|
||||
disconnect_peer_tcp(c, crypt_connection_id);
|
||||
list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);
|
||||
bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);
|
||||
return wipe_crypto_connection(c, crypt_connection_id);
|
||||
}
|
||||
|
||||
@ -2499,7 +2499,7 @@ Net_Crypto *new_net_crypto(DHT *dht)
|
||||
networking_registerhandler(dht->net, NET_PACKET_CRYPTO_HS, &udp_handle_packet, temp);
|
||||
networking_registerhandler(dht->net, NET_PACKET_CRYPTO_DATA, &udp_handle_packet, temp);
|
||||
|
||||
list_init(&temp->ip_port_list, sizeof(IP_Port));
|
||||
bs_list_init(&temp->ip_port_list, sizeof(IP_Port));
|
||||
return temp;
|
||||
}
|
||||
|
||||
@ -2573,7 +2573,7 @@ void kill_net_crypto(Net_Crypto *c)
|
||||
kill_TCP_connection(c->tcp_connections[i]);
|
||||
}
|
||||
|
||||
list_free(&c->ip_port_list);
|
||||
bs_list_free(&c->ip_port_list);
|
||||
networking_registerhandler(c->dht->net, NET_PACKET_COOKIE_REQUEST, NULL, NULL);
|
||||
networking_registerhandler(c->dht->net, NET_PACKET_COOKIE_RESPONSE, NULL, NULL);
|
||||
networking_registerhandler(c->dht->net, NET_PACKET_CRYPTO_HS, NULL, NULL);
|
||||
|
@ -189,7 +189,7 @@ typedef struct {
|
||||
/* The current optimal sleep time */
|
||||
uint32_t current_sleep_time;
|
||||
|
||||
LIST ip_port_list;
|
||||
BS_LIST ip_port_list;
|
||||
} Net_Crypto;
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user