Kaynağa Gözat

* Fixed a bug with transfer.mod and new dcc structure

svn: 1463
Bryan Drewery 21 yıl önce
ebeveyn
işleme
87d649de2c

+ 4 - 5
src/mod/share.mod/share.c

@@ -1453,7 +1453,7 @@ static void
 start_sending_users(int idx)
 start_sending_users(int idx)
 {
 {
   char share_file[1024] = "";
   char share_file[1024] = "";
-  int i = 1;
+  int i = 1, j = -1;
 
 
   egg_snprintf(share_file, sizeof share_file, "%s.share.%s.%li", tempdir, dcc[idx].nick, now);
   egg_snprintf(share_file, sizeof share_file, "%s.share.%s.%li", tempdir, dcc[idx].nick, now);
 
 
@@ -1469,7 +1469,7 @@ start_sending_users(int idx)
   }
   }
 */
 */
 
 
-  if ((i = raw_dcc_send(share_file, "*users", "(users)", share_file)) > 0) {
+  if ((i = raw_dcc_send(share_file, "*users", "(users)", share_file, &j)) > 0) {
     unlink(share_file);
     unlink(share_file);
     dprintf(idx, "s e %s\n", USERF_CANTSEND);
     dprintf(idx, "s e %s\n", USERF_CANTSEND);
     putlog(LOG_BOTS, "@", "%s -- can't send userfile",
     putlog(LOG_BOTS, "@", "%s -- can't send userfile",
@@ -1480,9 +1480,8 @@ start_sending_users(int idx)
   } else {
   } else {
     updatebot(-1, dcc[idx].nick, '+', 0, 0, NULL);
     updatebot(-1, dcc[idx].nick, '+', 0, 0, NULL);
     dcc[idx].status |= STAT_SENDING;
     dcc[idx].status |= STAT_SENDING;
-    i = dcc_total - 1;
-    strcpy(dcc[i].host, dcc[idx].nick); /* Store bot's nick */
-    dprintf(idx, "s us %lu %d %lu\n", iptolong(getmyip()), dcc[i].port, dcc[i].u.xfer->length);
+    strcpy(dcc[j].host, dcc[idx].nick); /* Store bot's nick */
+    dprintf(idx, "s us %lu %d %lu\n", iptolong(getmyip()), dcc[j].port, dcc[j].u.xfer->length);
 
 
     /* Unlink the file. We don't really care whether this causes problems
     /* Unlink the file. We don't really care whether this causes problems
      * for NFS setups. It's not worth the trouble.
      * for NFS setups. It's not worth the trouble.

+ 7 - 4
src/mod/transfer.mod/transfer.c

@@ -197,7 +197,7 @@ static void send_next_file(char *to)
     s = (char *) realloc(s, strlen(thisfile->dir) + strlen(thisfile->file) + 2);
     s = (char *) realloc(s, strlen(thisfile->dir) + strlen(thisfile->file) + 2);
     sprintf(s, "%s%s%s", thisfile->dir, thisfile->dir[0] ? "/" : "", thisfile->file);
     sprintf(s, "%s%s%s", thisfile->dir, thisfile->dir[0] ? "/" : "", thisfile->file);
   }
   }
-  x = raw_dcc_send(s1, thisfile->to, thisfile->nick, s);
+  x = raw_dcc_send(s1, thisfile->to, thisfile->nick, s, NULL);
   if (x == DCCSEND_OK) {
   if (x == DCCSEND_OK) {
     if (egg_strcasecmp(thisfile->to, thisfile->nick))
     if (egg_strcasecmp(thisfile->to, thisfile->nick))
       dprintf(DP_HELP, TRANSFER_FILE_ARRIVE, thisfile->to,
       dprintf(DP_HELP, TRANSFER_FILE_ARRIVE, thisfile->to,
@@ -1087,7 +1087,7 @@ static void dcc_get_pending(int idx, char *buf, int len)
  * Use raw_dcc_resend() and raw_dcc_send() instead of this function.
  * Use raw_dcc_resend() and raw_dcc_send() instead of this function.
  */
  */
 
 
-static int raw_dcc_resend_send(char *filename, char *nick, char *from, char *dir, int resend)
+static int raw_dcc_resend_send(char *filename, char *nick, char *from, char *dir, int resend, int *idx)
 {
 {
   int zz = -1;
   int zz = -1;
   int i;
   int i;
@@ -1163,6 +1163,9 @@ static int raw_dcc_resend_send(char *filename, char *nick, char *from, char *dir
   }
   }
   if (buf)
   if (buf)
     free(buf);
     free(buf);
+
+  if (idx)
+    *idx = i;
   return DCCSEND_OK;
   return DCCSEND_OK;
 }
 }
 
 
@@ -1177,9 +1180,9 @@ static int raw_dcc_resend(char *filename, char *nick, char *from, char *dir)
 
 
 /* Starts a DCC_SEND connection.
 /* Starts a DCC_SEND connection.
  */
  */
-int raw_dcc_send(char *filename, char *nick, char *from, char *dir)
+int raw_dcc_send(char *filename, char *nick, char *from, char *dir, int *idx)
 {
 {
-  return raw_dcc_resend_send(filename, nick, from, dir, 0);
+  return raw_dcc_resend_send(filename, nick, from, dir, 0, idx);
 }
 }
 #endif /* HUB */
 #endif /* HUB */
 
 

+ 1 - 1
src/mod/transfer.mod/transfer.h

@@ -30,7 +30,7 @@ enum {
         XFER_ACK_WITHOUT_OFFSET /* Skipped data is NOT counted in ack.  */
         XFER_ACK_WITHOUT_OFFSET /* Skipped data is NOT counted in ack.  */
 };
 };
 
 
-int raw_dcc_send(char *, char *, char *, char *);
+int raw_dcc_send(char *, char *, char *, char *, int *);
 
 
 #ifdef MAKING_TRANSFER
 #ifdef MAKING_TRANSFER
 #define TRANSFER_REGET_PACKETID 0xfeab
 #define TRANSFER_REGET_PACKETID 0xfeab

+ 4 - 5
src/mod/update.mod/update.c

@@ -287,7 +287,7 @@ static void start_sending_binary(int idx)
   /* module_entry *me; */
   /* module_entry *me; */
 #ifdef HUB
 #ifdef HUB
   char update_file[51] = "", update_fpath[DIRMAX] = "", tmpFile[1024] = "", *sysname = NULL;
   char update_file[51] = "", update_fpath[DIRMAX] = "", tmpFile[1024] = "", *sysname = NULL;
-  int i = 1;
+  int i = 1, j = -1;
 
 
   dcc[idx].status &= ~(STAT_OFFEREDU | STAT_SENDINGU);
   dcc[idx].status &= ~(STAT_OFFEREDU | STAT_SENDINGU);
 
 
@@ -340,7 +340,7 @@ static void start_sending_binary(int idx)
   end:;
   end:;
 */
 */
 
 
-  if ((i = raw_dcc_send(tmpFile, "*binary", "(binary)", tmpFile)) > 0) {
+  if ((i = raw_dcc_send(tmpFile, "*binary", "(binary)", tmpFile, &j)) > 0) {
     putlog(LOG_BOTS, "*", "%s -- can't send new binary",
     putlog(LOG_BOTS, "*", "%s -- can't send new binary",
 	   i == DCCSEND_FULL   ? "NO MORE DCC CONNECTIONS" :
 	   i == DCCSEND_FULL   ? "NO MORE DCC CONNECTIONS" :
 	   i == DCCSEND_NOSOCK ? "CAN'T OPEN A LISTENING SOCKET" :
 	   i == DCCSEND_NOSOCK ? "CAN'T OPEN A LISTENING SOCKET" :
@@ -349,9 +349,8 @@ static void start_sending_binary(int idx)
     dcc[idx].status &= ~(STAT_SENDINGU);
     dcc[idx].status &= ~(STAT_SENDINGU);
   } else {
   } else {
     dcc[idx].status |= STAT_SENDINGU;
     dcc[idx].status |= STAT_SENDINGU;
-    i = dcc_total - 1;
-    strcpy(dcc[i].host, dcc[idx].nick);		/* Store bot's nick */
-    dprintf(idx, "sb us %lu %hd %lu\n", iptolong(getmyip()), dcc[i].port, dcc[i].u.xfer->length);
+    strcpy(dcc[j].host, dcc[idx].nick);		/* Store bot's nick */
+    dprintf(idx, "sb us %lu %hd %lu\n", iptolong(getmyip()), dcc[j].port, dcc[j].u.xfer->length);
   }
   }
 #endif /* HUB */
 #endif /* HUB */
 }
 }