Fixed JOIN notify timeout handling.
[silc.git] / lib / silcclient / client_notify.c
index 005299c61f1a0610c9a3186c8c939f471ed5aca1..e1c969136c796ae6480798f455be29ee5e162c91 100644 (file)
@@ -56,9 +56,14 @@ static void silc_client_notify_resolved(SilcClient client,
   /* If entry is still invalid, resolving failed.  Finish notify processing. */
   if (notify->client_entry && !notify->client_entry->internal.valid) {
     /* If resolving timedout try it again many times. */
-    if (status != SILC_STATUS_ERR_TIMEDOUT || ++notify->resolve_retry > 1000)
+    if (status != SILC_STATUS_ERR_TIMEDOUT || ++notify->resolve_retry > 1000) {
       silc_fsm_next(notify->fsm, silc_client_notify_processed);
-    silc_client_unref_client(client, conn, notify->client_entry);
+
+      /* Unref client only in case of non-timeout error.  In case of timeout
+        occurred, the routine reprocessing the notify is expected not to
+        create new references of the entry. */
+      silc_client_unref_client(client, conn, notify->client_entry);
+    }
   }
 
   /* If no entries found, just finish the notify processing */
@@ -524,7 +529,7 @@ SILC_FSM_STATE(silc_client_notify_signoff)
   if (tmp && tmp_len > 128)
     tmp[128] = '\0';
 
-  if (packet->dst_id_type == SILC_ID_CHANNEL) 
+  if (packet->dst_id_type == SILC_ID_CHANNEL)
     if (silc_id_str2id(packet->dst_id, packet->dst_id_len, SILC_ID_CHANNEL,
                       &id.u.channel_id, sizeof(id.u.channel_id)))
       channel = silc_client_get_channel_by_id(client, conn, &id.u.channel_id);
@@ -690,7 +695,7 @@ SILC_FSM_STATE(silc_client_notify_nick_change)
   SilcNotifyType type = silc_notify_get_type(payload);
   SilcArgumentPayload args = silc_notify_get_args(payload);
   SilcClientEntry client_entry = NULL;
-  unsigned char *tmp, oldnick[128 + 1];
+  unsigned char *tmp, oldnick[256 + 1];
   SilcUInt32 tmp_len;
   SilcID id, id2;
   SilcBool valid;