updates.
[crypto.git] / apps / silcd / packet_send.c
index 81cdce5259489f4fafba35d7c302a6718bc2a1fb..25fc39072879b4404894bb70ae5e8357cfd4b17c 100644 (file)
@@ -2,7 +2,7 @@
 
   packet_send.c
 
-  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+  Author: Pekka Riikonen <priikone@silcnet.org>
 
   Copyright (C) 1997 - 2001 Pekka Riikonen
 
@@ -35,6 +35,10 @@ int silc_server_packet_send_real(SilcServer server,
 {
   int ret;
 
+  /* If disconnecting, ignore the data */
+  if (SILC_IS_DISCONNECTING(sock))
+    return -1;
+
   /* If rekey protocol is active we must assure that all packets are
      sent through packet queue. */
   if (SILC_SERVER_IS_REKEY(sock))
@@ -79,16 +83,24 @@ void silc_server_packet_send(SilcServer server,
   if (!sock)
     return;
 
+  /* If disconnecting, ignore the data */
+  if (SILC_IS_DISCONNECTING(sock))
+    return;
+
   /* Get data used in the packet sending, keys and stuff */
   switch(sock->type) {
   case SILC_SOCKET_TYPE_CLIENT:
-    dst_id = ((SilcClientEntry)sock->user_data)->id;
-    dst_id_type = SILC_ID_CLIENT;
+    if (sock->user_data) {
+      dst_id = ((SilcClientEntry)sock->user_data)->id;
+      dst_id_type = SILC_ID_CLIENT;
+    }
     break;
   case SILC_SOCKET_TYPE_SERVER:
   case SILC_SOCKET_TYPE_ROUTER:
-    dst_id = ((SilcServerEntry)sock->user_data)->id;
-    dst_id_type = SILC_ID_SERVER;
+    if (sock->user_data) {
+      dst_id = ((SilcServerEntry)sock->user_data)->id;
+      dst_id_type = SILC_ID_SERVER;
+    }
     break;
   default:
     break;
@@ -122,6 +134,10 @@ void silc_server_packet_send_dest(SilcServer server,
   unsigned char *dst_id_data = NULL;
   uint32 dst_id_len = 0;
 
+  /* If disconnecting, ignore the data */
+  if (SILC_IS_DISCONNECTING(sock))
+    return;
+
   SILC_LOG_DEBUG(("Sending packet, type %d", type));
 
   /* Get data used in the packet sending, keys and stuff */