/************************** Types and definitions ***************************/
/* Calls error command reply callback back to command sender. */
-#define ERROR_CALLBACK(error) \
+#define ERROR_CALLBACK(err) \
do { \
void *arg1 = NULL, *arg2 = NULL; \
if (cmd->status != SILC_STATUS_OK) \
silc_status_get_args(cmd->status, args, &arg1, &arg2); \
else \
- cmd->status = error; \
+ cmd->status = cmd->error = err; \
SILC_LOG_DEBUG(("Error in command reply: %s", \
silc_get_status_message(cmd->status))); \
silc_client_command_callback(cmd, arg1, arg2); \
client_entry = silc_client_get_client_by_id(client, conn, &id.u.client_id);
if (client_entry) {
- silc_client_unref_client(client, conn, client_entry);
+ silc_client_remove_from_channels(client, conn, client_entry);
silc_client_del_client(client, conn, client_entry);
+ silc_client_unref_client(client, conn, client_entry);
}
}
}
SILC_FSM_STATE(silc_client_command_reply_wait)
{
+ SilcClientCommandContext cmd = fsm_context;
+
SILC_LOG_DEBUG(("Wait for command reply"));
/** Wait for command reply */
silc_fsm_set_state_context(fsm, NULL);
- silc_fsm_next_later(fsm, silc_client_command_reply_timeout, 20, 0);
+ silc_fsm_next_later(fsm, silc_client_command_reply_timeout,
+ cmd->cmd != SILC_COMMAND_PING ? 25 : 60, 0);
return SILC_FSM_WAIT;
}
SilcClientConnection conn = cmd->conn;
SilcArgumentPayload args = NULL;
+ if (conn->internal->disconnected) {
+ SILC_LOG_DEBUG(("Command %s canceled", silc_get_command_name(cmd->cmd)));
+ silc_list_del(conn->internal->pending_commands, cmd);
+ return SILC_FSM_FINISH;
+ }
+
SILC_LOG_DEBUG(("Command %s timeout", silc_get_command_name(cmd->cmd)));
/* Timeout, reply not received in timely fashion */
silc_client_add_client(client, conn, nickname, username, realname,
&id.u.client_id, mode);
if (!client_entry) {
- ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+ ERROR_CALLBACK(SILC_STATUS_ERR_RESOURCE_LIMIT);
goto out;
}
silc_client_ref_client(client, conn, client_entry);
silc_client_add_client(client, conn, name, info, NULL,
&id.u.client_id, 0);
if (!client_entry) {
- ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+ ERROR_CALLBACK(SILC_STATUS_ERR_RESOURCE_LIMIT);
goto out;
}
silc_client_ref_client(client, conn, client_entry);
/* Remove the client from all channels and free it */
if (client_entry) {
+ silc_client_remove_from_channels(client, conn, client_entry);
silc_client_del_client(client, conn, client_entry);
silc_client_unref_client(client, conn, client_entry);
}
silc_client_command_callback(cmd, channel);
/* Now delete the channel. */
+ silc_client_empty_channel(client, conn, channel);
silc_client_del_channel(client, conn, channel);
out: