Merge commit 'origin/silc.1.1.branch'
[silc.git] / lib / silccore / silcpacket.c
index f552ca6d1741aebf31648e1c694d34c302792ac3..26f721f56f0d34448725a4c7a1e43673702e1429 100644 (file)
@@ -559,7 +559,8 @@ silc_packet_engine_start(SilcRng rng, SilcBool router,
   if (!engine)
     return NULL;
 
-  engine->contexts = silc_hash_table_alloc(0, silc_hash_ptr, NULL, NULL, NULL,
+  engine->contexts = silc_hash_table_alloc(NULL, 0, silc_hash_ptr,
+                                          NULL, NULL, NULL,
                                           silc_packet_engine_context_destr,
                                           engine, TRUE);
   if (!engine->contexts) {
@@ -768,10 +769,10 @@ SilcPacketStream silc_packet_stream_create(SilcPacketEngine engine,
 
   /* If this is UDP stream, allocate UDP remote stream hash table */
   if (!engine->udp_remote && silc_socket_stream_is_udp(stream, NULL))
-    engine->udp_remote = silc_hash_table_alloc(0, silc_hash_string, NULL,
-                                              silc_hash_string_compare, NULL,
-                                              silc_packet_engine_hash_destr,
-                                              NULL, TRUE);
+    engine->udp_remote =
+      silc_hash_table_alloc(NULL, 0, silc_hash_string_case, NULL,
+                           silc_hash_string_case_compare, NULL,
+                           silc_packet_engine_hash_destr, NULL, TRUE);
 
   silc_mutex_unlock(engine->lock);
 
@@ -1494,7 +1495,7 @@ static inline void silc_packet_send_ctr_increment(SilcPacketStream stream,
 
     SILC_LOG_HEXDUMP(("IV"), ret_iv, 8);
 
-    /* Set new nonce to counter block */
+    /* Set new IV to counter block */
     memcpy(iv + 4, ret_iv, 8);
   } else {
     /* Increment 64-bit packet counter */
@@ -1509,7 +1510,7 @@ static inline void silc_packet_send_ctr_increment(SilcPacketStream stream,
   SILC_LOG_HEXDUMP(("Counter Block"), iv, 16);
 }
 
-/* Internal routine to assemble outgoing packet.  Assembles and encryptes
+/* Internal routine to assemble outgoing packet.  Assembles and encrypts
    the packet.  The silc_packet_stream_write needs to be called to send it
    after this returns TRUE. */
 
@@ -1618,6 +1619,12 @@ static inline SilcBool silc_packet_send_raw(SilcPacketStream stream,
 
   silc_mutex_lock(stream->lock);
 
+  if (silc_unlikely(stream->destroyed)) {
+    SILC_LOG_DEBUG(("Stream %p is destroyed, cannot send packet", stream));
+    silc_mutex_unlock(stream->lock);
+    return FALSE;
+  }
+
   /* Get packet pointer from the outgoing buffer */
   if (silc_unlikely(!silc_packet_send_prepare(stream, truelen + padlen + ivlen
                                              + psnlen, hmac, &packet))) {