summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Core/ConnectionManager.cpp2
-rw-r--r--src/Core/ConnectionManager.h4
-rw-r--r--src/mad-core.cpp4
-rw-r--r--src/madc.cpp8
4 files changed, 10 insertions, 8 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index ba78a98..b338f62 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -90,6 +90,8 @@ ConnectionManager::ConnectionManager() {
catch(Net::Exception &e) {
// TODO: Log error
}
+
+ refreshPollfds();
}
ConnectionManager::~ConnectionManager() {
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h
index b252910..cbfc812 100644
--- a/src/Core/ConnectionManager.h
+++ b/src/Core/ConnectionManager.h
@@ -59,8 +59,8 @@ class ConnectionManager {
ConnectionManager();
virtual ~ConnectionManager();
- void wait(int timeout) {
- poll(pollfds.data(), pollfds.size(), timeout);
+ bool wait(int timeout) {
+ return (poll(pollfds.data(), pollfds.size(), timeout) > 0);
}
void run();
diff --git a/src/mad-core.cpp b/src/mad-core.cpp
index 461f595..c46b932 100644
--- a/src/mad-core.cpp
+++ b/src/mad-core.cpp
@@ -26,8 +26,8 @@ int main() {
Mad::Core::ConnectionManager connectionManager;
while(true) {
- connectionManager.run();
- connectionManager.wait(10000);
+ if(connectionManager.wait(10000))
+ connectionManager.run();
}
Mad::Net::Connection::deinit();
diff --git a/src/madc.cpp b/src/madc.cpp
index 8104d0b..aaf7197 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -33,8 +33,8 @@ int main() {
while(connection.isConnecting()) {
struct pollfd fd = connection.getPollfd();
- poll(&fd, 1, 10000);
- connection.sendReceive(fd.revents);
+ if(poll(&fd, 1, 10000) > 0)
+ connection.sendReceive(fd.revents);
}
connection.send(Mad::Net::Packet(0x0001, 0xABCD));
@@ -42,8 +42,8 @@ int main() {
while(!connection.sendQueueEmpty()) {
struct pollfd fd = connection.getPollfd();
- poll(&fd, 1, 10000);
- connection.sendReceive(fd.revents);
+ if(poll(&fd, 1, 10000) > 0)
+ connection.sendReceive(fd.revents);
}
}
catch(Mad::Net::Exception &e) {