From 9256ad9bd3d7d65732498b370501f3d970c83f0c Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 4 Nov 2011 13:27:32 +0100 Subject: changed the tryagain --- src/networkdiscovery.cpp | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'src/networkdiscovery.cpp') diff --git a/src/networkdiscovery.cpp b/src/networkdiscovery.cpp index b0b7131..6039bef 100644 --- a/src/networkdiscovery.cpp +++ b/src/networkdiscovery.cpp @@ -22,6 +22,12 @@ NetworkDiscovery::NetworkDiscovery(QObject *parent) { NetworkDiscovery::~NetworkDiscovery() { delete _networkManager; delete _server; + foreach(QProcess* p, _clientProcessToIfNameMap.keys()) { + delete p; + } + foreach(interfaceconfiguration* i, _ifcMap.values()) { + delete i; + } } @@ -365,7 +371,6 @@ void NetworkDiscovery::handleProcessStarted() { * checkConnectivity() @see NetworkDiscovery::checkConnectivity() * Unexpected exit: * emit updateIfStatus() to process exited unexpected - * TODO:: the reason for the unexpected exit should be presented in the logfile. * * @param exitCode * @@ -506,6 +511,7 @@ bool NetworkDiscovery::checkConnectivityViaTcp(QString server) { } else { return true; } + delete tcpSocket; } @@ -777,31 +783,43 @@ void NetworkDiscovery::killDHCPCD() { if (p->exitCode() > 0) qxtLog->debug() << _tag << " [tryAgain] " << p->errorString(); - delete p; + delete p; } -/* - *TODO: to be bug fixed - *TODO: do it with kill and not QProcess("killall cdhcpcd") - *TODO: still some bugs. if you press tryAgain it can happen that the app stops with the mainscreen. - *TODO: reproducible: start normal with user choice. plug out the cable. press continue. abort screen should appear. - *TODO: press tryAgain. - */ -void NetworkDiscovery::tryAgain() { +/**/ +void NetworkDiscovery::prepareTryAgain() { // kill all cdhcpcd processes killDHCPCD(); /* - foreach(Q_PID pid , _pidsList) { - if (kill(pid,SIGKILL) <= -1) - qDebug() << _tag << " error: trying to kill process: " << pid << " error: " << strerror(errno); - } - */ + foreach(Q_PID pid , _pidsList) { + if (kill(pid,SIGKILL) <= -1) + qDebug() << _tag << " error: trying to kill process: " << pid << " error: " << strerror(errno); + } + */ // reset everything delete _networkManager; delete _server; + foreach(QProcess* p, _clientProcessToIfNameMap.keys()) + { + delete p; + } + foreach(interfaceconfiguration* i, _ifcMap.values()) + { + delete i; + } +} + + + +/* + *TODO: to be bug fixed + *TODO: do it with kill and not QProcess("killall cdhcpcd") + */ +void NetworkDiscovery::tryAgain() { + prepareTryAgain(); initAndRun(_serverIp, _userChoice, _autoUp, _pathToLogFile, _serverPath, DEFAULT_PATHTODHCPCDEXE); } -- cgit v1.2.3-55-g7522