silc_client_protocols_register();
/* Initialize the scheduler */
- client->schedule = silc_schedule_init(&client->io_queue,
- &client->timeout_queue,
- &client->generic_queue, 5000);
+ client->schedule = silc_schedule_init(200);
if (!client->schedule)
return FALSE;
{
SILC_LOG_DEBUG(("Stopping client"));
- /* Stop the scheduler, although it might be already stopped. This
- doesn't hurt anyone. This removes all the tasks and task queues,
- as well. */
silc_schedule_stop(client->schedule);
silc_schedule_uninit(client->schedule);
/* Register task that will receive the async connect and will
read the result. */
- ctx->task = silc_task_register(ctx->client->io_queue, sock,
- silc_client_connect_to_server_start,
- (void *)ctx, 0, 0,
- SILC_TASK_FD,
- SILC_TASK_PRI_NORMAL);
- silc_task_reset_iotype(ctx->task, SILC_TASK_WRITE);
- silc_schedule_set_listen_fd(ctx->client->schedule, sock, ctx->task->iomask);
+ ctx->task = silc_schedule_task_add(ctx->client->schedule, sock,
+ silc_client_connect_to_server_start,
+ (void *)ctx, 0, 0,
+ SILC_TASK_FD,
+ SILC_TASK_PRI_NORMAL);
+ silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE);
ctx->sock = sock;
SILC_CLIENT_REGISTER_CONNECTION_FOR_IO(fd);
/* Execute the protocol */
- silc_protocol_execute(protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(protocol, client->schedule, 0, 0);
return TRUE;
}
/* Unregister old connection try */
silc_schedule_unset_listen_fd(client->schedule, fd);
silc_net_close_connection(fd);
- silc_task_unregister(client->io_queue, ctx->task);
+ silc_schedule_task_del(client->schedule, ctx->task);
/* Try again */
silc_client_connect_to_server_internal(ctx);
ctx->host, strerror(opt));
silc_schedule_unset_listen_fd(client->schedule, fd);
silc_net_close_connection(fd);
- silc_task_unregister(client->io_queue, ctx->task);
+ silc_schedule_task_del(client->schedule, ctx->task);
silc_free(ctx);
/* Notify application of failure */
}
silc_schedule_unset_listen_fd(client->schedule, fd);
- silc_task_unregister(client->io_queue, ctx->task);
+ silc_schedule_task_del(client->schedule, ctx->task);
silc_free(ctx);
if (!silc_client_start_key_exchange(client, conn, fd)) {
silc_client_connect_to_server_final);
/* Execute the protocol */
- silc_protocol_execute(sock->protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
}
/* Finalizes the connection to the remote SILC server. This is called
/* Register re-key timeout */
conn->rekey->timeout = client->params->rekey_secs;
conn->rekey->context = (void *)client;
- silc_task_register(client->timeout_queue, conn->sock->sock,
+ silc_schedule_task_add(client->schedule, conn->sock->sock,
silc_client_rekey_callback,
(void *)conn->sock, conn->rekey->timeout, 0,
SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
SilcClient client = (SilcClient)parser_context->context;
/* Parse the packet */
- silc_task_register(client->timeout_queue, parser_context->sock->sock,
+ silc_schedule_task_add(client->schedule, parser_context->sock->sock,
silc_client_packet_parse_real,
(void *)parser_context, 0, 1,
SILC_TASK_TIMEOUT,
* success message is for whatever protocol is executing currently.
*/
if (sock->protocol)
- silc_protocol_execute(sock->protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
break;
case SILC_PACKET_FAILURE:
/*
break;
/* Let the protocol handle the packet */
- silc_protocol_execute(sock->protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
} else {
SILC_LOG_ERROR(("Received Key Exchange packet but no key exchange "
"protocol active, packet dropped."));
proto_ctx->packet = silc_packet_context_dup(packet);
/* Let the protocol handle the packet */
- silc_protocol_execute(sock->protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
} else {
SilcClientKEInternalContext *proto_ctx =
(SilcClientKEInternalContext *)sock->protocol->context;
break;
/* Let the protocol handle the packet */
- silc_protocol_execute(sock->protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
}
} else {
SILC_LOG_ERROR(("Received Key Exchange 1 packet but no key exchange "
proto_ctx->packet = silc_packet_context_dup(packet);
/* Let the protocol handle the packet */
- silc_protocol_execute(sock->protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
} else {
SilcClientKEInternalContext *proto_ctx =
(SilcClientKEInternalContext *)sock->protocol->context;
break;
/* Let the protocol handle the packet */
- silc_protocol_execute(sock->protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
}
} else {
SILC_LOG_ERROR(("Received Key Exchange 2 packet but no key exchange "
/* Let the protocol handle the packet */
if (proto_ctx->responder == FALSE)
- silc_protocol_execute(sock->protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
else
/* Let the protocol handle the packet */
- silc_protocol_execute(sock->protocol, client->timeout_queue,
+ silc_protocol_execute(sock->protocol, client->schedule,
0, 100000);
} else {
SILC_LOG_ERROR(("Received Re-key done packet but no re-key "
silc_schedule_unset_listen_fd(client->schedule, sock->sock);
/* Unregister all tasks */
- silc_task_unregister_by_fd(client->io_queue, sock->sock);
- silc_task_unregister_by_fd(client->timeout_queue, sock->sock);
+ silc_schedule_task_del_by_fd(client->schedule, sock->sock);
+ silc_schedule_task_del_by_fd(client->schedule, sock->sock);
/* Close the actual connection */
silc_net_close_connection(sock->sock);
sock->protocol->protocol->type ==
SILC_PROTOCOL_CLIENT_CONNECTION_AUTH) {
sock->protocol->state = SILC_PROTOCOL_STATE_ERROR;
- silc_protocol_execute_final(sock->protocol, client->timeout_queue);
+ silc_protocol_execute_final(sock->protocol, client->schedule);
sock->protocol = NULL;
/* The application will recall this function with these protocols
(the ops->connect client operation). */
return;
} else {
sock->protocol->state = SILC_PROTOCOL_STATE_ERROR;
- silc_protocol_execute_final(sock->protocol, client->timeout_queue);
+ silc_protocol_execute_final(sock->protocol, client->schedule);
sock->protocol = NULL;
}
}
sock->protocol = protocol;
/* Run the protocol */
- silc_protocol_execute(protocol, client->timeout_queue, 0, 0);
+ silc_protocol_execute(protocol, client->schedule, 0, 0);
/* Re-register re-key timeout */
- silc_task_register(client->timeout_queue, sock->sock,
+ silc_schedule_task_add(client->schedule, sock->sock,
silc_client_rekey_callback,
context, conn->rekey->timeout, 0,
SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
/* Error occured during protocol */
- silc_protocol_cancel(protocol, client->timeout_queue);
+ silc_protocol_cancel(protocol, client->schedule);
silc_protocol_free(protocol);
sock->protocol = NULL;
if (ctx->packet)