silc_status_get_args(cmd->status, args, &arg1, &arg2); \
else \
cmd->status = error; \
- silc_client_command_callback(cmd, arg1, arg2); \
+ SILC_LOG_DEBUG(("Error in command reply: %s", \
+ silc_get_status_message(cmd->status))); \
+ silc_client_command_callback(cmd, arg1, arg2); \
} while(0)
/* Check for error */
#define CHECK_STATUS(msg) \
- SILC_LOG_DEBUG(("Start")); \
+ SILC_LOG_DEBUG(("%s", silc_get_command_name(cmd->cmd))); \
if (cmd->error != SILC_STATUS_OK) { \
if (cmd->verbose) \
SAY(cmd->conn->client, cmd->conn, SILC_CLIENT_MESSAGE_ERROR, \
ERROR_CALLBACK(cmd->error); \
silc_client_command_process_error(cmd, state_context, cmd->error); \
silc_fsm_next(fsm, silc_client_command_reply_process); \
- return SILC_FSM_YIELD; \
+ return SILC_FSM_CONTINUE; \
}
/* Check for correct arguments */
silc_argument_get_arg_num(args) > max) { \
ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS); \
silc_fsm_next(fsm, silc_client_command_reply_process); \
- return SILC_FSM_YIELD; \
+ return SILC_FSM_CONTINUE; \
}
#define SAY cmd->conn->client->internal->ops->say
while ((cb = silc_list_get(cmd->reply_callbacks)))
if (!cb->do_not_call) {
silc_va_copy(cp, ap);
- cb->do_not_call = cb->reply(cmd->conn->client, cmd->conn, cmd->cmd,
- cmd->status, cmd->error, cb->context, cp);
+ cb->do_not_call = !cb->reply(cmd->conn->client, cmd->conn, cmd->cmd,
+ cmd->status, cmd->error, cb->context, cp);
va_end(cp);
}
/* Find the command pending reply */
silc_mutex_lock(conn->internal->lock);
silc_list_start(conn->internal->pending_commands);
- while ((cmd = silc_list_get(conn->internal->pending_commands)))
+ while ((cmd = silc_list_get(conn->internal->pending_commands))) {
if ((cmd->cmd == command || cmd->cmd == SILC_COMMAND_NONE)
- && cmd->cmd_ident == cmd_ident)
+ && cmd->cmd_ident == cmd_ident) {
+ silc_list_del(conn->internal->pending_commands, cmd);
break;
+ }
+ }
silc_mutex_unlock(conn->internal->lock);
if (!cmd) {
SILC_FSM_STATE(silc_client_command_reply_processed)
{
SilcClientCommandContext cmd = fsm_context;
+ SilcClientConnection conn = cmd->conn;
SilcCommandPayload payload = state_context;
silc_command_payload_free(payload);
SILC_STATUS_IS_ERROR(cmd->status))
return SILC_FSM_FINISH;
+ /* Add back to pending command reply list */
+ silc_mutex_lock(conn->internal->lock);
+ cmd->resolved = FALSE;
+ silc_list_add(conn->internal->pending_commands, cmd);
+ silc_mutex_unlock(conn->internal->lock);
+
/** Wait more command payloads */
silc_fsm_next(fsm, silc_client_command_reply_wait);
return SILC_FSM_CONTINUE;
ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
goto out;
}
+ silc_client_ref_client(client, conn, client_entry);
} else {
silc_client_update_client(client, conn, client_entry,
nickname, username, realname, mode);
ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
goto out;
}
+ silc_client_ref_client(client, conn, client_entry);
} else {
silc_client_update_client(client, conn, client_entry,
name, info, NULL, 0);
}
/* Update the client entry */
+ silc_mutex_lock(conn->internal->lock);
if (!silc_idcache_update(conn->internal->client_cache,
conn->internal->local_entry,
&conn->local_entry->id,
conn->local_entry->nickname_normalized,
tmp, TRUE)) {
silc_free(tmp);
+ silc_mutex_unlock(conn->internal->lock);
ERROR_CALLBACK(SILC_STATUS_ERR_BAD_NICKNAME);
goto out;
}
- memcpy(conn->local_entry->nickname, nick, strlen(nick));
+ silc_mutex_unlock(conn->internal->lock);
+ memset(conn->local_entry->nickname, 0, sizeof(conn->local_entry->nickname));
+ memcpy(conn->local_entry->nickname, nick, len);
conn->local_entry->nickname_normalized = tmp;
silc_buffer_enlarge(conn->internal->local_idp, idp_len);
silc_buffer_put(conn->internal->local_idp, idp, idp_len);
silc_client_nickname_format(client, conn, conn->local_entry);
+ silc_packet_set_ids(conn->stream, SILC_ID_CLIENT, conn->local_id, 0, NULL);
/* Notify application */
silc_client_command_callback(cmd, conn->local_entry,
SilcInt64 diff;
diff = silc_time() - SILC_PTR_TO_64(cmd->context);
- SAY(client, conn, SILC_CLIENT_MESSAGE_INFO,
- "Ping reply from %s: %d second%s", conn->remote_host,
- (int)diff, diff == 1 ? "" : "s");
+ if (cmd->verbose)
+ SAY(client, conn, SILC_CLIENT_MESSAGE_INFO,
+ "Ping reply from %s: %d second%s", conn->remote_host,
+ (int)diff, diff == 1 ? "" : "s");
/* Notify application */
silc_client_command_callback(cmd);
/* Mode */
SILC_GET32_MSB(mode, client_mode_list.data);
+ SILC_LOG_DEBUG(("id %s", silc_id_render(&id.u.client_id, SILC_ID_CLIENT)));
+
/* Get client entry */
client_entry = silc_client_get_client_by_id(client, conn, &id.u.client_id);
if (!client_entry)