[eggheads-patches] PATCH1.5: delchan_during_joinbind_1.5.patch

Fabian Knittel fknittel at gmx.de
Thu Oct 26 10:30:23 CST 2000


[ delchan_during_joinbind_1.5.patch ]

This is the fix requested by Tothwolf a few days ago. Channels may now
be deleted during the JOIN bind call.

If you now of other places where doing weird stuff from bind procs
causes trouble, please tell me.

Fabian

--
Fabian Knittel <fknittel at gmx.de> -- http://www.esc-web.de/fabian/
Signed or encrypted mail preferred.    PGP DSA key ID: 0x838B4D20
-------------- next part --------------
diff -urN --exclude-from=/home/fabian/.diffex eggdrop1.5~/doc/UPDATES1.5 eggdrop1.5/doc/UPDATES1.5
--- eggdrop1.5~/doc/UPDATES1.5	Thu Oct 26 17:33:31 2000
+++ eggdrop1.5/doc/UPDATES1.5	Thu Oct 26 17:39:58 2000
@@ -4,6 +4,8 @@
 
 1.5.5
 Found by  Fixed by  What...
+Tothwolf  Fabian    Could not remove joining channel from procs called by
+                    JOIN bind.
 fabulous  Fabian    The filesys module did not support remotely linked files.
                     Instead, the bot crashed in various places and didn't even
                     attempt to save/load the link information.
diff -urN --exclude-from=/home/fabian/.diffex eggdrop1.5~/src/mod/irc.mod/chan.c eggdrop1.5/src/mod/irc.mod/chan.c
--- eggdrop1.5~/src/mod/irc.mod/chan.c	Mon Oct 23 23:19:30 2000
+++ eggdrop1.5/src/mod/irc.mod/chan.c	Wed Oct 25 15:38:43 2000
@@ -1468,6 +1468,7 @@
 static int gotjoin(char *from, char *chname)
 {
   char *nick, *p, *newmode, buf[UHOSTLEN], *uhost = buf;
+  char *ch_dname = NULL;
   int ok = 1;
   struct chanset_t *chan;
   memberlist *m;
@@ -1493,9 +1494,15 @@
      * name now. This will happen when we initially join the channel, as we
      * dont know the unique channel name that the server has made up. <cybah>
      */  
-    if (strlen(chname) > (CHANNEL_ID_LEN + 1)) {
-      egg_snprintf(buf, UHOSTLEN, "!%s", chname + (CHANNEL_ID_LEN + 1));
-      chan = findchan_by_dname(buf);
+     int	l_chname = strlen(chname);
+
+    if (l_chname > (CHANNEL_ID_LEN + 1)) {
+      ch_dname = nmalloc(l_chname + 1);
+      if (ch_dname) {
+	egg_snprintf(ch_dname, l_chname + 2, "!%s",
+		     chname + (CHANNEL_ID_LEN + 1));
+	chan = findchan_by_dname(ch_dname);
+      }
     }
   } else if (!chan) {
     /* As this is not a !chan, we need to search for it by display name now.
@@ -1555,11 +1562,28 @@
 	strcpy(m->userhost, uhost);
 	m->user = u;
 	m->flags |= STOPWHO;
+
 	check_tcl_join(nick, uhost, u, chan->dname);
-	/* The tcl binding might have deleted the current user. Use the record
-	 * saved in the channel record as that always gets updated.
-	 */
+
+	/* The tcl binding might have deleted the current user and the
+	 * current channel, so we'll now have to re-check whether they
+	 * both still exist.
+	 */ 
+	chan = findchan(chname);
+	if (!chan) {
+	  if (ch_dname)
+	    chan = findchan_by_dname(ch_dname);
+	  else
+	    chan = findchan_by_dname(chname);
+	}
+	if (!chan)
+	  /* The channel doesn't exist anymore, so get out of here. */
+	  goto exit;
+
+	/* The record saved in the channel record always gets updated,
+	   so we can use that. */
 	u = m->user;
+
 	if (newmode)
 	  do_embedded_mode(chan, nick, m, newmode);
 	if (match_my_nick(nick)) {
@@ -1649,7 +1673,7 @@
 		    dprintf(DP_SERVER, "KICK %s %s :%s\n", chname, m->nick,
 			    IRC_YOUREBANNED);
 		    m->flags |= SENTKICK;
-		    return 0;
+		    goto exit;
 		  }
 	    }
 	  }
@@ -1692,6 +1716,10 @@
       }
     }
   }
+
+exit:
+  if (ch_dname)
+    nfree(ch_dname);
   return 0;
 }
 




More information about the Patches mailing list