X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fclient.c;h=67dfff2b78b622a05e791036977e6b9759ddda66;hb=157f4732888e39853b3de6617eeeffd910a4a06d;hp=8c950acb0f8baa70ea47720479f0bf730aef3145;hpb=57085fa9a76d72b3af854133659ca3732bad3cc2;p=silc.git diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index 8c950acb..67dfff2b 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -778,7 +778,7 @@ static bool silc_client_packet_parse(SilcPacketParserContext *parser_context, SilcPacketContext *packet = parser_context->packet; SilcPacketType ret; - if (conn && conn->hmac_receive) + if (conn && conn->hmac_receive && conn->sock == sock) conn->psn_receive = parser_context->packet->sequence + 1; /* Parse the packet immediately */ @@ -1231,6 +1231,8 @@ void silc_client_close_connection(SilcClient client, { int del = FALSE; + SILC_LOG_DEBUG(("Start")); + if (!sock || (sock && conn->sock == sock)) del = TRUE; if (!sock) @@ -1339,6 +1341,22 @@ void silc_client_close_connection(SilcClient client, silc_socket_free(sock); } +/* Called when we receive disconnection packet from server. This + closes our end properly and displays the reason of the disconnection + on the screen. */ + +SILC_TASK_CALLBACK(silc_client_disconnected_by_server_later) +{ + SilcClient client = (SilcClient)context; + SilcSocketConnection sock; + + SILC_CLIENT_GET_SOCK(client, fd, sock); + if (sock == NULL) + return; + + silc_client_close_connection(client, sock, sock->user_data); +} + /* Called when we receive disconnection packet from server. This closes our end properly and displays the reason of the disconnection on the screen. */ @@ -1357,7 +1375,12 @@ void silc_client_disconnected_by_server(SilcClient client, silc_free(msg); SILC_SET_DISCONNECTED(sock); - silc_client_close_connection(client, sock, sock->user_data); + + /* Close connection through scheduler. */ + silc_schedule_task_add(client->schedule, sock->sock, + silc_client_disconnected_by_server_later, + client, 0, 1, SILC_TASK_TIMEOUT, + SILC_TASK_PRI_NORMAL); } /* Received error message from server. Display it on the screen.