[PATCH] dcc-send-limiter.c fixes

Piotr Krukowiecki <[email protected]> Fri, 10 Jan 2003 15:03:20 +0100
Newsgroups gmane.network.irc.irssi.devel
Message-ID <[email protected]>
Hi

Fixed a little bit the plugin:

+       * fixed unnecesary lag in sending data when send is resume
+       * sends that were started before the module was loaded
+         now are being limited as well

I've been using it for about a week with avg 2 sends at once, and have no
problems with it. It would be nice if you could apply the patch


-- 
Piotrek
irc: #debian.pl
Mors Drosophilis melanogastribus!
dcc-send-limiter.c.diff (text/plain, 1.7 KB)
--- dcc-send-limiter-orig.c	Sat Jan  4 13:44:18 2003
+++ dcc-send-limiter.c	Sat Jan  4 14:06:56 2003
@@ -21,6 +21,10 @@
     	  that didn't contain any module data
     	* fixed crash when initiating dcc send
 
+    Modified 2002/12/31 by Piotr Krukowiecki (Happy New Year! ;))
+    	* fixed unnecesary lag in sending data when send is resume
+	* sends that were started before the module was loaded 
+	  now are being limited as well
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -37,6 +41,7 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+
 #define MODULE_NAME "irc/dcc/limiter"
 #define HAVE_CONFIG_H
 
@@ -162,7 +167,7 @@ static void sig_dcc_connected(SEND_DCC_R
 	mdcc = g_new0(MODULE_SEND_DCC_REC, 1);
 	MODULE_DATA_SET(dcc, mdcc);
 	mdcc->timeout_tag = -1;
-	mdcc->skip_bytes = 0;
+	mdcc->skip_bytes = dcc->transfd; /* now it works correct with dcc resume - doesn't wait 30s with sending data */
 	mdcc->max_speed = settings_get_int("dcc_send_top_speed");
 
 	/* get starttime in milliseconds */
@@ -192,10 +197,20 @@ static void sig_dcc_destroyed(SEND_DCC_R
 
 void dcc_send_limiter_init(void)
 {
+	GSList *tmp;
 	settings_add_int("dcc", "dcc_send_top_speed", 30);
 
 	signal_add_last("dcc connected", (SIGNAL_FUNC) sig_dcc_connected);
 	signal_add_first("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed);
+	
+	/* Limit already existing sends */
+	for (tmp = dcc_conns; tmp != NULL; tmp = tmp->next) {
+		SEND_DCC_REC *dcc = tmp->data;
+		if (!IS_DCC_SEND(dcc)) continue;
+		if (!dcc_is_connected(dcc)) continue;
+		
+		sig_dcc_connected(dcc);
+	}
 
         module_register("dcc_send_limiter", "core");
 }