diff -Nuar chestnut-dialer-0.3.3.orig/chestnut_dialer/connection.py chestnut-dialer-0.3.3/chestnut_dialer/connection.py --- chestnut-dialer-0.3.3.orig/chestnut_dialer/connection.py 2007-02-20 10:34:16.000000000 +0200 +++ chestnut-dialer-0.3.3/chestnut_dialer/connection.py 2013-05-02 15:49:47.000000000 +0300 @@ -202,6 +200,7 @@ except OSError: debug_msg(_("cannot chagne file permitions on '%s'") % file_name, 2) return (file_name, f) + def _connection_init(self): account = self.account if not self._callback_answer_mode: @@ -380,19 +380,46 @@ self.pppd_exit_code = code / 256 return 0 return 1 + def iteration(self): - account = self.account + account = self.account + + # Vladimir Smolyar, 02.05.2013: Check whether the interface is (still) up + if not (self.linkname and re.search(r' /dev/null" % (chestnut_dialer.config.ifconfig, self.linkname)), re.M)): + self._interface_up = 0 + + if not self._interface_up: pppd_kiled = 0 buf = "" - t = time.time() + t = time.time() while time.time() - t < 0.1: if select.select([self._pppd_pty], [], [], 0.02)[0]: try: buf += os.read(self._pppd_pty, 1) except OSError: break - else: + else: break + if buf == "" and not self._is_pppd_live(): pppd_kiled = 1 + # Vladimir Smolyar, 02.05.2013: + elif buf =="": + # the buffer is empty + if self.connected: + #chestnut-dialer believes that it is connected, but + # 1) the _interface_up = 0 + # 2) buf == "" + # So let's check if the pppd is reconnecting already: + if select.select([self._pppd_pty], [], [], 20)[0]: + # yes, it is reconnecting just now + return + # no, it is not reconnecting while it should. + # So let's send a signal to it + debug_msg("Sending SIGHUP",3) + os.kill(self._pppd, signal.SIGHUP) + + if len(buf): buf = buf.replace("\r", "") self.text_queue.put(buf) @@ -401,6 +428,7 @@ self._pppd_chars = lines[-1] lines[-1:] = [] for s in lines: + #killing because of a low speed if not self.speed: m = self._speed_re.match(s) if m: @@ -474,7 +503,22 @@ self.connected = 1 if account['connect_program']: os.system(account['connect_program']) + else: + # the interface is down, thus it is not connected + self.connected = 0 + if not pppd_kiled: return + + # Vladimir Smolyar, 02.05.2013: + # Deleting the chat and password temporary files moved down, + # after the pppd is surely killed. + # Otherwise it leads to an error when pppd wishes to reconnect and + # cannot find the temporary chat file. + + if self._is_pppd_live(): return + + # Vladimir Smolyar, 02.05.2013: + # deleting the chat and password temporary files if self._chat_temp_file: debug_msg(_("removing chat temp file"), 3) os.unlink(self._chat_temp_file) @@ -483,7 +527,8 @@ debug_msg(_("removing password temp file"), 3) os.unlink(self._passwd_temp_file) self._passwd_temp_file = None - if self._is_pppd_live(): return + + os.close(self._pppd_pty) if self._passwdfdr: try: os.close(self._passwdfdr) diff -Nuar chestnut-dialer-0.3.3.orig/chestnut_dialer/gtk2_ui/application.py chestnut-dialer-0.3.3/chestnut_dialer/gtk2_ui/application.py --- chestnut-dialer-0.3.3.orig/chestnut_dialer/gtk2_ui/application.py 2007-02-19 02:05:09.000000000 +0200 +++ chestnut-dialer-0.3.3/chestnut_dialer/gtk2_ui/application.py 2013-05-02 15:43:09.000000000 +0300 @@ -270,8 +270,14 @@ self.set_mode("Connecting") self.set_icon("connecting") self.update_main_window_title() + + # Vladimir Smolyar, 02.05.2013: + # delete the timer in order to avoid multiple connection monitor timers + if self.connection_monitor_tid != None: + gobject.source_remove(self.connection_monitor_tid) self.connection_monitor_tid = gobject.timeout_add(300, self.gtk_timeout, self.connection_monitor_signal) + def on_connection_setup(self): self.set_mode("Status") self.set_icon("connected") @@ -281,14 +287,20 @@ self.connection_monitor_tid = gobject.timeout_add( int(self.config.monitor_period * 1000), self.gtk_timeout, self.connection_monitor_signal) + # Vladimir Smolyar, 02.05.2013: + # delete the timer in order to avoid multiple status update timers + if self.update_status_tid != None: + gobject.source_remove(self.update_status_tid) self.update_status_tid = gobject.timeout_add( int(self.config.status_refresh_period * 1000), self.update_status_monitor) + def on_connection_setup_extra(self): try: action = self.config.gtk2_ui.on_connect except AttributeError: action = "" if action == "iconify" and self.main_window: self.main_window.iconify() + def on_connection_stop(self, reason): gobject.source_remove(self.connection_monitor_tid) if self.update_status_tid != None: