dcc: Disable timeout timer when not in use
This should mean that hexchat never *needs* to wake-up unless prompted by socket activity (assuming that the lag-o-meter is not enabled).
This commit is contained in:
		
							parent
							
								
									7dca220486
								
							
						
					
					
						commit
						25e197a6c8
					
				
					 3 changed files with 16 additions and 11 deletions
				
			
		| 
						 | 
					@ -63,6 +63,9 @@
 | 
				
			||||||
#define lseek _lseeki64
 | 
					#define lseek _lseeki64
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* interval timer to detect timeouts */
 | 
				
			||||||
 | 
					static int timeout_timer = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static char *dcctypes[] = { "SEND", "RECV", "CHAT", "CHAT" };
 | 
					static char *dcctypes[] = { "SEND", "RECV", "CHAT", "CHAT" };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct dccstat_info dccstat[] = {
 | 
					struct dccstat_info dccstat[] = {
 | 
				
			||||||
| 
						 | 
					@ -82,6 +85,7 @@ static void dcc_close (struct DCC *dcc, int dccstat, int destroy);
 | 
				
			||||||
static gboolean dcc_send_data (GIOChannel *, GIOCondition, struct DCC *);
 | 
					static gboolean dcc_send_data (GIOChannel *, GIOCondition, struct DCC *);
 | 
				
			||||||
static gboolean dcc_read (GIOChannel *, GIOCondition, struct DCC *);
 | 
					static gboolean dcc_read (GIOChannel *, GIOCondition, struct DCC *);
 | 
				
			||||||
static gboolean dcc_read_ack (GIOChannel *source, GIOCondition condition, struct DCC *dcc);
 | 
					static gboolean dcc_read_ack (GIOChannel *source, GIOCondition condition, struct DCC *dcc);
 | 
				
			||||||
 | 
					static int dcc_check_timeouts (void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int new_id(void)
 | 
					static int new_id(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -233,9 +237,9 @@ is_dcc_completed (struct DCC *dcc)
 | 
				
			||||||
	return FALSE;
 | 
						return FALSE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* this is called from hexchat.c:hexchat_check_dcc() every 1 second. */
 | 
					/* this is called by timeout_timer every 1 second. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					int
 | 
				
			||||||
dcc_check_timeouts (void)
 | 
					dcc_check_timeouts (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct DCC *dcc;
 | 
						struct DCC *dcc;
 | 
				
			||||||
| 
						 | 
					@ -292,6 +296,7 @@ dcc_check_timeouts (void)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		list = next;
 | 
							list = next;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
| 
						 | 
					@ -419,6 +424,11 @@ dcc_close (struct DCC *dcc, int dccstat, int destroy)
 | 
				
			||||||
		g_free (dcc->destfile);
 | 
							g_free (dcc->destfile);
 | 
				
			||||||
		g_free (dcc->nick);
 | 
							g_free (dcc->nick);
 | 
				
			||||||
		g_free (dcc);
 | 
							g_free (dcc);
 | 
				
			||||||
 | 
							if (dcc_list == NULL && timeout_timer != 0)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								fe_timeout_remove (timeout_timer);
 | 
				
			||||||
 | 
								timeout_timer = 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2222,6 +2232,10 @@ new_dcc (void)
 | 
				
			||||||
	dcc->sok = -1;
 | 
						dcc->sok = -1;
 | 
				
			||||||
	dcc->fp = -1;
 | 
						dcc->fp = -1;
 | 
				
			||||||
	dcc_list = g_slist_prepend (dcc_list, dcc);
 | 
						dcc_list = g_slist_prepend (dcc_list, dcc);
 | 
				
			||||||
 | 
						if (timeout_timer == 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							timeout_timer = fe_timeout_add (1000, dcc_check_timeouts, NULL);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return dcc;
 | 
						return dcc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -110,7 +110,6 @@ gboolean is_dcc_completed (struct DCC *dcc);
 | 
				
			||||||
void dcc_abort (session *sess, struct DCC *dcc);
 | 
					void dcc_abort (session *sess, struct DCC *dcc);
 | 
				
			||||||
void dcc_get (struct DCC *dcc);
 | 
					void dcc_get (struct DCC *dcc);
 | 
				
			||||||
int dcc_resume (struct DCC *dcc);
 | 
					int dcc_resume (struct DCC *dcc);
 | 
				
			||||||
void dcc_check_timeouts (void);
 | 
					 | 
				
			||||||
void dcc_change_nick (server *serv, char *oldnick, char *newnick);
 | 
					void dcc_change_nick (server *serv, char *oldnick, char *newnick);
 | 
				
			||||||
void dcc_notify_kill (struct server *serv);
 | 
					void dcc_notify_kill (struct server *serv);
 | 
				
			||||||
struct DCC *dcc_write_chat (char *nick, char *text);
 | 
					struct DCC *dcc_write_chat (char *nick, char *text);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -354,13 +354,6 @@ doover:
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					 | 
				
			||||||
hexchat_check_dcc (void)	/* this gets called every 1 second */
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	dcc_check_timeouts ();
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* these are only run if the lagometer is enabled */
 | 
					/* these are only run if the lagometer is enabled */
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
hexchat_lag_check (void)   /* this gets called every 30 seconds */
 | 
					hexchat_lag_check (void)   /* this gets called every 30 seconds */
 | 
				
			||||||
| 
						 | 
					@ -406,7 +399,6 @@ irc_init (session *sess)
 | 
				
			||||||
					     notify_checklist, NULL);
 | 
										     notify_checklist, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, NULL);
 | 
						fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, NULL);
 | 
				
			||||||
	fe_timeout_add (1000, hexchat_check_dcc, NULL);
 | 
					 | 
				
			||||||
	if (prefs.hex_gui_lagometer)
 | 
						if (prefs.hex_gui_lagometer)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		fe_timeout_add (500, hexchat_lag_check_update, NULL);
 | 
							fe_timeout_add (500, hexchat_lag_check_update, NULL);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue