Explorar el Código

* Port [3913] to 1.2.16 from trunk
* Fixed bots getting confused about their hub/uplink after userfile transfer fails (fixes #61)



svn: 3914

Bryan Drewery hace 17 años
padre
commit
a3836d2902
Se han modificado 2 ficheros con 15 adiciones y 9 borrados
  1. 2 0
      doc/UPDATES
  2. 13 9
      src/mod/share.mod/share.c

+ 2 - 0
doc/UPDATES

@@ -15,6 +15,8 @@
 * Added 'link_cleartext' which allows disabling of cleartext bot linking (needed for upgrades)
 * Fixed bug where salts were not written to binary when first generating them
 * Fixed countless buffer overflows. (fixes #226)
+* Fixed a rare segfault on userfile transfer timeouts
+* Fixed bots getting confused about their hub/uplink after userfile transfer fails (fixes #61)
 
 1.2.15 - http://wraith.botpack.net/milestone/1.2.15
 * Fix a possible segfault when binaries compiled wrong

+ 13 - 9
src/mod/share.mod/share.c

@@ -68,6 +68,8 @@ static struct delay_mode *start_delay = NULL;
 /* Prototypes */
 static void start_sending_users(int);
 static void shareout_but(int, const char *, ...)  __attribute__ ((format(printf, 2, 3)));
+
+static bool cancel_user_xfer_staylinked = 0;
 static void cancel_user_xfer(int, void *);
 
 #include "share.h"
@@ -998,8 +1000,10 @@ hook_read_userfile()
       if (dcc[i].type && (dcc[i].type->flags & DCT_BOT) && (dcc[i].status & STAT_SHARE) && !(dcc[i].status & STAT_AGGRESSIVE)
           && (1)) {
         /* Cancel any existing transfers */
-        if (dcc[i].status & STAT_SENDING)
-          cancel_user_xfer(-i, 0);
+        if (dcc[i].status & STAT_SENDING) {
+          cancel_user_xfer_staylinked = 1;
+          cancel_user_xfer(i, 0);
+        }
         dprintf(i, "s u?\n");
         dcc[i].status |= STAT_OFFERED;
       }
@@ -1024,7 +1028,8 @@ static void
 share_end(int idx, char *par)
 {
   putlog(LOG_BOTS, "*", "Ending sharing with %s (%s).", dcc[idx].nick, par);
-  cancel_user_xfer(-idx, 0);
+  cancel_user_xfer_staylinked = 1;
+  cancel_user_xfer(idx, 0);
   dcc[idx].status &= ~(STAT_SHARE | STAT_GETTING | STAT_SENDING | STAT_OFFERED | STAT_AGGRESSIVE);
   dcc[idx].u.bot->uff_flags = 0;
 }
@@ -1462,11 +1467,8 @@ static void (*def_dcc_bot_kill) (int, void *) = 0;
 static void
 cancel_user_xfer(int idx, void *x)
 {
-  int i, j = -1, k = 0;
-
-  if (idx < 0) {
-    idx = -idx;
-    k = 1;
+  int i, j = -1;
+  if (cancel_user_xfer_staylinked) {
     /* turn off sharing flag */
     updatebot(-1, dcc[idx].nick, '-', 0, 0, 0, NULL);
   }
@@ -1504,8 +1506,10 @@ cancel_user_xfer(int idx, void *x)
       putlog(LOG_BOTS, "*", "(Userlist transmit aborted.)");
     }
   }
-  if (!k)
+  if (!cancel_user_xfer_staylinked)
     def_dcc_bot_kill(idx, x);
+ 
+  cancel_user_xfer_staylinked = 0;
 }
 
 void