summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas2011-08-30 15:03:25 +0200
committerNiklas2011-08-30 15:03:25 +0200
commit34e522bcad11b1264a92e46379991fb4d344f1d1 (patch)
treee317e1b5f910e390ee4b1eae4e90df91ca78dc91
parenttried to fix the message loss problem, but failed. TODO: debug and socket sni... (diff)
downloadfbgui-34e522bcad11b1264a92e46379991fb4d344f1d1.tar.gz
fbgui-34e522bcad11b1264a92e46379991fb4d344f1d1.tar.xz
fbgui-34e522bcad11b1264a92e46379991fb4d344f1d1.zip
added check for file existens. renamed the dhcpcd bin to customdhcpcd. temporal solution for the message loss problem => added a sleep(1) function after every send operation. this makes the programm a bit slower but it solves the problem, we now receive every message (issue 339)
-rwxr-xr-xworkspace/LogReceiver/LogReceiverbin113415 -> 117864 bytes
-rw-r--r--workspace/LogReceiver/logreceiver.cpp49
-rw-r--r--workspace/LogReceiver/logreceiver.h6
-rw-r--r--workspace/customdhcpcd/src/Makefile2
-rwxr-xr-xworkspace/customdhcpcd/src/customdhcpcdbin0 -> 173204 bytes
-rw-r--r--workspace/customdhcpcd/src/dhcpcd.c2
-rw-r--r--workspace/customdhcpcd/src/logwriter.c1
7 files changed, 49 insertions, 11 deletions
diff --git a/workspace/LogReceiver/LogReceiver b/workspace/LogReceiver/LogReceiver
index 7fee3c5..a2450ce 100755
--- a/workspace/LogReceiver/LogReceiver
+++ b/workspace/LogReceiver/LogReceiver
Binary files differ
diff --git a/workspace/LogReceiver/logreceiver.cpp b/workspace/LogReceiver/logreceiver.cpp
index 127d69e..9f73862 100644
--- a/workspace/LogReceiver/logreceiver.cpp
+++ b/workspace/LogReceiver/logreceiver.cpp
@@ -39,14 +39,23 @@ void LogReceiver::initAndRun(QString serverPath, QString pathToExe,
close();
*/
// emit signal to the gui that a critial error occoured
- qDebug() << "--- \t [LogReceiver::initAndRun] Unable to start server:"
+ QString errorInfo("Unable to start server: ");
+ qDebug() << "--- \t [LogReceiver::initAndRun] " + errorInfo
<< server->errorString();
+ emit abortBoot(errorInfo + server->errorString());
return;
}
connect(server, SIGNAL(newConnection()), this, SLOT(handleNewConnection()));
pathToDhcpcdExe = pathToExe;
+ // check if the path to the customdhcpcd file is correct
+ QFileInfo fInfo(pathToDhcpcdExe);
+ if (!fInfo.exists()) {
+ qDebug() << "couldn't find customdhcpcd exe. Please check the path to this file.";
+ emit abortBoot("couldn't find customdhcpcd exe. Please check the path to this file.");
+ return;
+ }
if (args != NULL && !args->isEmpty()) {
qDebug() << "--- \t [LogReceiver::initAndRun] added additional args";
@@ -250,23 +259,46 @@ void LogReceiver::checkInternetConnectionViaTCP(QString ifName) {
void LogReceiver::handleNewConnection() {
qDebug() << "New Connection arrived";
- QLocalSocket * client = server ->nextPendingConnection();
+ /*QLocalSocket **/ client = server ->nextPendingConnection();
clients.insert(client, client);
- connect(client, SIGNAL(disconnected()), client, SLOT(deleteLater()));
+ connect(client, SIGNAL(disconnected()), this, SLOT(handleClientDisconnect()));
connect(client, SIGNAL(readyRead()), this, SLOT(handleNewInput()));
}
+void LogReceiver::handleClientDisconnect() {
+ QLocalSocket* socket = qobject_cast<QLocalSocket *> (QObject::sender());
+
+ QLocalSocket * client = clients.value(socket);
+
+ qDebug() << "disconnect client";
+ handleNewInput(client);
+ client->deleteLater();
+}
+
+void LogReceiver::handleNewInput(QLocalSocket * client) {
+ QString data(client->readAll());
+
+ data = data.trimmed();
+ qDebug() << data;
+ QStringList lines = data.split("\n");
+
+ for (int i = 0; i < lines.length(); i++) {
+ handleNewInputLine(lines.at(i));
+ }
+}
+
void LogReceiver::handleNewInput() {
- QObject* sender = const_cast<QObject*> (QObject::sender());
- QLocalSocket* socket = static_cast<QLocalSocket*> (sender);
+ //QObject* sender = const_cast<QObject*> (QObject::sender());
+ //QLocalSocket* socket = static_cast<QLocalSocket*> (sender);
+ QLocalSocket* socket = qobject_cast<QLocalSocket * >(QObject::sender());
QLocalSocket * client = clients.value(socket);
QString data(client->readAll());
data = data.trimmed();
-
+ qDebug() << data;
QStringList lines = data.split("\n");
for (int i=0; i < lines.length(); i++) {
@@ -283,7 +315,7 @@ void LogReceiver::handleNewInputLine(QString data) {
QString msg = logMsg.section(";", 3, 3);
int st = s_state.trimmed().toInt();
int sst = s_subState.trimmed().toInt();
- qDebug() << logMsg;
+ //qDebug() << logMsg;
switch (st) {
case LOG_INFO:
switch (sst) {
@@ -320,7 +352,7 @@ void LogReceiver::handleNewInputLine(QString data) {
emit changeProgressBarValue(interface, 80);
break;
case DHCPCD_EXIT:
- emit changeProgressBarValue(interface, 100);
+ //emit changeProgressBarValue(interface, 100);
break;
case DHCPCD_LOG:
@@ -353,6 +385,7 @@ void LogReceiver::handleProcessFinished(int exitCode,
else {
qDebug() << "process normal exit";
qDebug() << "check internet connction";
+ emit changeProgressBarValue(ifName, 100);
emit updateStatusLabel(ifName, "check connectivity");
//checkInternetConnection(ifName);
checkInternetConnectionViaTCP(ifName);
diff --git a/workspace/LogReceiver/logreceiver.h b/workspace/LogReceiver/logreceiver.h
index 6611d15..6b32aa8 100644
--- a/workspace/LogReceiver/logreceiver.h
+++ b/workspace/LogReceiver/logreceiver.h
@@ -16,7 +16,7 @@ class LogReceiver: public QObject {
Q_OBJECT
#define DEFAULT_QTSOCKETADDRESS "/var/tmp/qt_c_socket_default"
-#define DEFAULT_PATHTODHCPCDEXE "/home/niklas/fbgui/workspace/customdhcpcd/src/dhcpcd"
+#define DEFAULT_PATHTODHCPCDEXE "/home/niklas/fbgui/workspace/customdhcpcd/src/customdhcpcd"
public:
LogReceiver();
@@ -32,6 +32,7 @@ private slots:
void handleNewInputLine(QString data);
void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void handleProcessStarted();
+ void handleClientDisconnect();
signals:
void addNewInterface(QString ifName);
@@ -47,6 +48,7 @@ private:
//QMap<int, QNetworkInterface > interfacesMap;
//QMap<QString, int> indexToIfaceNameMap;
QMap<QLocalSocket *, QLocalSocket *> clients;
+ QLocalSocket * client;
QMap<QProcess*, QString> clientProcessToIfNameMap;
QString pathToDhcpcdExe;
QStringList dhcpcdArguments;
@@ -54,6 +56,8 @@ private:
QNetworkAccessManager *accessManager;
int numberOfProcesses;
+ void handleNewInput(QLocalSocket * client);
+
void runDHCPCD(QList<QString> &interfaces);
void runDHCPCD(QString interface);
QList<QString>checkCarrierState(QList<QString> &interfaces);
diff --git a/workspace/customdhcpcd/src/Makefile b/workspace/customdhcpcd/src/Makefile
index 13d9f28..7f90db4 100644
--- a/workspace/customdhcpcd/src/Makefile
+++ b/workspace/customdhcpcd/src/Makefile
@@ -2,7 +2,7 @@
# Our mk stubs also work with GNU make.
# Copyright 2008 Roy Marples <roy@marples.name>
-PROG= dhcpcd
+PROG= customdhcpcd
SRCS= arp.c client.c common.c configure.c dhcp.c dhcpcd.c duid.c \
info.c interface.c ipv4ll.c logger.c logwriter.c signal.c socket.c
MAN= dhcpcd.8
diff --git a/workspace/customdhcpcd/src/customdhcpcd b/workspace/customdhcpcd/src/customdhcpcd
new file mode 100755
index 0000000..38b7696
--- /dev/null
+++ b/workspace/customdhcpcd/src/customdhcpcd
Binary files differ
diff --git a/workspace/customdhcpcd/src/dhcpcd.c b/workspace/customdhcpcd/src/dhcpcd.c
index f8f003c..9f91239 100644
--- a/workspace/customdhcpcd/src/dhcpcd.c
+++ b/workspace/customdhcpcd/src/dhcpcd.c
@@ -665,9 +665,9 @@ abort:
free (dhcpcd_skiproutes);
#endif
- closeQtLoggerSocket();
logger (LOG_INFO, "exiting");
logToQt(LOG_INFO, DHCPCD_EXIT, "exiting due abort");
+ closeQtLoggerSocket();
exit (retval);
/* NOTREACHED */
}
diff --git a/workspace/customdhcpcd/src/logwriter.c b/workspace/customdhcpcd/src/logwriter.c
index 2ef257c..a6adbe3 100644
--- a/workspace/customdhcpcd/src/logwriter.c
+++ b/workspace/customdhcpcd/src/logwriter.c
@@ -97,6 +97,7 @@ void sendToQt(log_msg * msg) {
syslog (LOG_ERR, "[fbgui] ERROR writing to socket: [%d:%d] %s (%s)", msg->status, msg->substatus, msg->msg, msg->device);
// fprintf(stdout, "ERROR writing to socket: %s", msg);
}
+ sleep(1);
}
void logToQt(int status, int substatus, const char * msg) {