/* Do not send data to disconnected connection */
if (SILC_IS_DISCONNECTING(sock) || SILC_IS_DISCONNECTED(sock)) {
SILC_LOG_DEBUG(("Disconnected socket connection, cannot send"));
+ SILC_SET_CONNECTION_FOR_INPUT(server->schedule, fd);
+ SILC_UNSET_OUTBUF_PENDING(sock);
+ silc_buffer_clear(sock->outbuf);
return;
}
SilcIDListData idata = (SilcIDListData)sock->user_data;
int ret;
+ if (SILC_IS_DISCONNECTING(sock) || SILC_IS_DISCONNECTED(sock)) {
+ SILC_LOG_DEBUG(("Connection is disconnected"));
+ goto out;
+ }
+
server->stat.packets_received++;
/* Parse the packet */
silc_server_packet_parse_real(server->schedule, server, 0, sock->sock,
parser_context);
+ if (SILC_IS_DISCONNECTING(sock) || SILC_IS_DISCONNECTED(sock)) {
+ SILC_LOG_DEBUG(("Connection is disconnected"));
+ return FALSE;
+ }
+
/* Reprocess data since we'll return FALSE here. This is because
the idata->receive_key might have become valid in the last packet
and we want to call this processor with valid cipher. */
silc_server_packet_parse_real(server->schedule, server, 0, sock->sock,
parser_context);
break;
- default:
- return TRUE;
}
return TRUE;
"Router"), tmp[0] ? tmp : ""));
SILC_SET_DISCONNECTED(sock);
+ silc_socket_set_qos(sock, 0, 0, 0, 0, NULL);
silc_schedule_task_add(server->schedule, sock->sock,
silc_server_close_connection_final,
(void *)sock, 0, 1, SILC_TASK_TIMEOUT,
silc_ske_free(ctx->ske);
silc_socket_free(sock);
silc_free(ctx);
+
+ /* Disconnect since we failed to rekey, the keys are probably wrong. */
+ silc_server_disconnect_remote(server, sock,
+ SILC_STATUS_ERR_KEY_EXCHANGE_FAILED, NULL);
+
+ /* Reconnect */
+ if (sock->type != SILC_SOCKET_TYPE_CLIENT)
+ silc_server_create_connections(server);
}
/* A timeout callback for the re-key. We will be the initiator of the
silc_schedule_task_add(server->schedule, sock->sock,
silc_server_rekey_timeout,
proto_ctx,
- server->config->key_exchange_timeout, 0,
+ (idata->rekey->timeout >
+ server->config->key_exchange_timeout ?
+ idata->rekey->timeout :
+ server->config->key_exchange_timeout * 4), 0,
SILC_TASK_TIMEOUT,
SILC_TASK_PRI_LOW);