More string format fixes in silcd and client libary
[silc.git] / apps / silcd / command.c
index f68edccdc589984e4c364c4e4220df0ad1636201..cafbb7c7fe0d5c2477ef90c0e9bf5f5c4ce030d4 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2008 Pekka Riikonen
+  Copyright (C) 1997 - 2009 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -339,7 +339,7 @@ SILC_TASK_CALLBACK(silc_server_command_pending_timeout)
   SilcBuffer tmpreply;
   int i;
 
-  SILC_LOG_DEBUG(("Timeout pending command"));
+  SILC_LOG_DEBUG(("Timeout pending command %p", reply));
 
   /* Allocate temporary and bogus command reply context */
   cmdr = silc_calloc(1, sizeof(*cmdr));
@@ -2379,7 +2379,7 @@ SILC_SERVER_CMD_FUNC(join)
        channel will be global, based on our router name. */
     if (!serv[0] && !server->config->local_channels) {
       if (!server->standalone) {
-       silc_snprintf(serv, sizeof(serv), server->router->server_name);
+       silc_snprintf(serv, sizeof(serv), "%s", server->router->server_name);
       } else {
        SilcServerConfigRouter *router;
        router = silc_server_config_get_primary_router(server);
@@ -4068,20 +4068,36 @@ SILC_TASK_CALLBACK(silc_server_command_detach_cb)
   SilcClientID *client_id = (SilcClientID *)q->sock;
   SilcClientEntry client;
   SilcPacketStream sock;
+  SilcIDListData idata;
+
 
   client = silc_idlist_find_client_by_id(server->local_list, client_id,
                                         TRUE, NULL);
   if (client && client->connection) {
     sock = client->connection;
 
+    SILC_LOG_DEBUG(("Detaching client %s",
+                   silc_id_render(client->id, SILC_ID_CLIENT)));
+
     /* Stop rekey for the client. */
     silc_server_stop_rekey(server, client);
 
+    /* Abort any active protocol */
+    idata = silc_packet_get_context(sock);
+    if (idata && idata->sconn && idata->sconn->op) {
+      SILC_LOG_DEBUG(("Abort active protocol"));
+      silc_async_abort(idata->sconn->op, NULL, NULL);
+      idata->sconn->op = NULL;
+    }
+
     /* Close the connection on our side */
     client->router = NULL;
     client->connection = NULL;
     silc_server_close_connection(server, sock);
 
+    /* Mark the client as locally detached. */
+    client->local_detached = TRUE;
+
     /*
      * Decrement the user count; we'll increment it if the user resumes on our
      * server.