if (!client->sockets) {
client->sockets = silc_calloc(1, sizeof(*client->sockets));
- client->sockets[0] = sock;
+ client->sockets[0] = silc_socket_dup(sock);
client->sockets_count = 1;
return;
}
for (i = 0; i < client->sockets_count; i++) {
if (client->sockets[i] == NULL) {
- client->sockets[i] = sock;
+ client->sockets[i] = silc_socket_dup(sock);
return;
}
}
client->sockets = silc_realloc(client->sockets, sizeof(*client->sockets) *
(client->sockets_count + 1));
- client->sockets[client->sockets_count] = sock;
+ client->sockets[client->sockets_count] = silc_socket_dup(sock);
client->sockets_count++;
}
for (i = 0; i < client->sockets_count; i++) {
if (client->sockets[i] == sock) {
+ silc_socket_free(sock);
client->sockets[i] = NULL;
return;
}
protocol as context. */
proto_ctx = silc_calloc(1, sizeof(*proto_ctx));
proto_ctx->client = (void *)client;
- proto_ctx->sock = conn->sock;
+ proto_ctx->sock = silc_socket_dup(conn->sock);
proto_ctx->rng = client->rng;
proto_ctx->responder = FALSE;
proto_ctx->send_packet = silc_client_protocol_ke_send_packet;
if (ctx->dest_id)
silc_free(ctx->dest_id);
ctx->sock->protocol = NULL;
+ silc_socket_free(ctx->sock);
/* Notify application of failure */
client->ops->connect(client, ctx->sock->user_data, FALSE);
if (ctx->dest_id)
silc_free(ctx->dest_id);
conn->sock->protocol = NULL;
+ silc_socket_free(ctx->sock);
/* Notify application of failure */
client->ops->connect(client, ctx->sock->user_data, FALSE);
silc_free(ctx->auth_data);
if (ctx->ske)
silc_ske_free(ctx->ske);
+ silc_socket_free(ctx->sock);
silc_free(ctx);
conn->sock->protocol = NULL;
}
SilcClient client = (SilcClient)parser_context->context;
/* Parse the packet */
-
-#if 0
- /* If REKEY protocol is active we must proccess the packets synchronously
- since we must assure that incoming packets that are encrypted with
- the old key is processed before the new keys is set to use. */
- if (SILC_CLIENT_IS_REKEY(parser_context->sock))
- silc_client_packet_parse_real(client->timeout_queue, SILC_TASK_READ,
- (void *)parser_context,
- parser_context->sock->sock);
- else
-#endif
- silc_task_register(client->timeout_queue, parser_context->sock->sock,
- silc_client_packet_parse_real,
- (void *)parser_context, 0, 1,
- SILC_TASK_TIMEOUT,
- SILC_TASK_PRI_NORMAL);
+ silc_task_register(client->timeout_queue, parser_context->sock->sock,
+ silc_client_packet_parse_real,
+ (void *)parser_context, 0, 1,
+ SILC_TASK_TIMEOUT,
+ SILC_TASK_PRI_NORMAL);
}
/* Parses the packet type and calls what ever routines the packet type
to the protocol. */
proto_ctx = silc_calloc(1, sizeof(*proto_ctx));
proto_ctx->client = (void *)client;
- proto_ctx->sock = sock;
+ proto_ctx->sock = silc_socket_dup(sock);
proto_ctx->responder = FALSE;
proto_ctx->pfs = conn->rekey->pfs;
silc_packet_context_free(ctx->packet);
if (ctx->ske)
silc_ske_free(ctx->ske);
+ silc_socket_free(ctx->sock);
silc_free(ctx);
return;
}
-#if 0
- /* Take the keys into use */
- if (ctx->pfs == TRUE)
- silc_client_protocol_rekey_generate_pfs(client, ctx);
- else
- silc_client_protocol_rekey_generate(client, ctx);
-#endif
-
/* Cleanup */
silc_protocol_free(protocol);
sock->protocol = NULL;
silc_packet_context_free(ctx->packet);
if (ctx->ske)
silc_ske_free(ctx->ske);
+ silc_socket_free(ctx->sock);
silc_free(ctx);
}