@@ -168,8 +168,6 @@ non_null() static void group_delete(GC_Session *c, GC_Chat *chat);
168
168
non_null () static void group_cleanup (const GC_Session * c , GC_Chat * chat );
169
169
non_null () static bool group_exists (const GC_Session * c , const uint8_t * chat_id );
170
170
non_null () static void add_tcp_relays_to_chat (const GC_Session * c , GC_Chat * chat );
171
- non_null (1 , 2 ) nullable (4 )
172
- static bool peer_delete (const GC_Session * c , GC_Chat * chat , uint32_t peer_number , void * userdata );
173
171
non_null () static void create_gc_session_keypair (const Logger * log , const Random * rng , uint8_t * public_key ,
174
172
uint8_t * secret_key );
175
173
non_null () static size_t load_gc_peers (GC_Chat * chat , const GC_SavedPeerInfo * addrs , uint16_t num_addrs );
@@ -837,6 +835,21 @@ static int saved_peer_index(const GC_Chat *chat, const uint8_t *public_key)
837
835
return -1 ;
838
836
}
839
837
838
+ /** @brief Removes entry containing `public_key` from the saved peers list. */
839
+ non_null ()
840
+ static void saved_peers_remove_entry (GC_Chat * chat , const uint8_t * public_key )
841
+ {
842
+ const int idx = saved_peer_index (chat , public_key );
843
+
844
+ if (idx < 0 ) {
845
+ return ;
846
+ }
847
+
848
+ chat -> saved_peers [idx ] = (GC_SavedPeerInfo ) {
849
+ 0
850
+ };
851
+ }
852
+
840
853
/** @brief Returns the index of the first vacant entry in saved peers list.
841
854
*
842
855
* If `public_key` is non-null and already exists in the list, its index will be returned.
@@ -6701,6 +6714,7 @@ void gc_callback_rejected(const Messenger *m, gc_rejected_cb *function)
6701
6714
*
6702
6715
* Return true on success.
6703
6716
*/
6717
+ non_null (1 , 2 ) nullable (4 )
6704
6718
static bool peer_delete (const GC_Session * c , GC_Chat * chat , uint32_t peer_number , void * userdata )
6705
6719
{
6706
6720
GC_Peer * peer = get_gc_peer (chat , peer_number );
@@ -6709,17 +6723,23 @@ static bool peer_delete(const GC_Session *c, GC_Chat *chat, uint32_t peer_number
6709
6723
return false;
6710
6724
}
6711
6725
6726
+ GC_Connection * gconn = & peer -> gconn ;
6727
+
6712
6728
// We need to save some peer info for the callback before deleting it
6713
- const bool peer_confirmed = peer -> gconn . confirmed ;
6729
+ const bool peer_confirmed = gconn -> confirmed ;
6714
6730
const GC_Peer_Id peer_id = peer -> peer_id ;
6715
6731
uint8_t nick [MAX_GC_NICK_SIZE ];
6716
6732
const uint16_t nick_length = peer -> nick_length ;
6717
- const GC_Exit_Info exit_info = peer -> gconn . exit_info ;
6733
+ const GC_Exit_Info exit_info = gconn -> exit_info ;
6718
6734
6719
6735
assert (nick_length <= MAX_GC_NICK_SIZE );
6720
6736
memcpy (nick , peer -> nick , nick_length );
6721
6737
6722
- gcc_peer_cleanup (chat -> mem , & peer -> gconn );
6738
+ if (exit_info .exit_type == GC_EXIT_TYPE_KICKED ) {
6739
+ saved_peers_remove_entry (chat , gconn -> addr .public_key .enc );
6740
+ }
6741
+
6742
+ gcc_peer_cleanup (chat -> mem , gconn );
6723
6743
6724
6744
-- chat -> numpeers ;
6725
6745
0 commit comments