From b132c92b3ae3aeee293a4e815336cac76c7cfe69 Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Sun, 17 Nov 2013 01:04:49 +0100 Subject: Assoc's array is now allocated dynamically and per default much smaller (320 entries). id_hash() was not at all working as expected for very small bucket size (when (size / 4) was zero). Simplified to be trivially correct. Also added a used flag on adding an entry, which is set by callers if they have that association in active use. Those get priority over unused entries on collision. Fleshed out test to be at least elementary useful. Each group chat now uses an own, small assoc (80 entries). --- toxcore/Messenger.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'toxcore/Messenger.c') diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 49cffc98..904c3ecc 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -786,7 +786,7 @@ int add_groupchat(Messenger *m) for (i = 0; i < m->numchats; ++i) { if (m->chats[i] == NULL) { - Group_Chat *newchat = new_groupchat(m->net, m->dht->assoc); + Group_Chat *newchat = new_groupchat(m->net); if (newchat == NULL) return -1; @@ -805,7 +805,7 @@ int add_groupchat(Messenger *m) if (temp == NULL) return -1; - temp[m->numchats] = new_groupchat(m->net, m->dht->assoc); + temp[m->numchats] = new_groupchat(m->net); if (temp[m->numchats] == NULL) return -1; @@ -1820,6 +1820,18 @@ void do_messenger(Messenger *m) #ifdef LOGGING if (unix_time() > lastdump + DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS) { + loglog(" = = = = = = = = \n"); + Assoc_status(m->dht->assoc); + + if (m->numchats > 0) { + size_t c; + + for (c = 0; c < m->numchats; c++) { + loglog("---------------- \n"); + Assoc_status(m->chats[c]->assoc); + } + } + loglog(" = = = = = = = = \n"); lastdump = unix_time(); @@ -2010,7 +2022,7 @@ static int messenger_load_state_callback(void *outer, uint8_t *data, uint32_t le load_keys(m->net_crypto, &data[sizeof(uint32_t)]); if (m->dht->assoc) - Assoc_self_client_id_changed(m->dht->assoc); + Assoc_self_client_id_changed(m->dht->assoc, m->net_crypto->self_public_key); } else return -1; /* critical */ -- cgit v1.2.3