return check

This commit is contained in:
Andreas Volz 2009-12-01 23:31:49 +01:00
parent e23c8c4750
commit c505052353
3 changed files with 22 additions and 4 deletions

View file

@ -25,6 +25,7 @@
#ifndef __DBUSXX_EVENTLOOP_INTEGRATION_H #ifndef __DBUSXX_EVENTLOOP_INTEGRATION_H
#define __DBUSXX_EVENTLOOP_INTEGRATION_H #define __DBUSXX_EVENTLOOP_INTEGRATION_H
#include <errno.h>
#include "api.h" #include "api.h"
#include "dispatcher.h" #include "dispatcher.h"
#include "util.h" #include "util.h"
@ -66,10 +67,11 @@ public:
{ {
//pipe to create a new fd used to unlock a dispatcher at any //pipe to create a new fd used to unlock a dispatcher at any
// moment (used by leave function) // moment (used by leave function)
pipe(_pipe); int ret = pipe(_pipe);
if (ret == -1) throw Error("PipeError:errno", toString(errno).c_str());
_fdunlock[0] = _pipe[0]; _fdunlock[0] = _pipe[0];
_fdunlock[1] = _pipe[1]; _fdunlock[1] = _pipe[1];
} }
~BusDispatcher() ~BusDispatcher()

View file

@ -25,6 +25,9 @@
#ifndef __DBUSXX_UTIL_H #ifndef __DBUSXX_UTIL_H
#define __DBUSXX_UTIL_H #define __DBUSXX_UTIL_H
#include <sstream>
#include <iostream>
#include <iomanip>
#include "api.h" #include "api.h"
#include "debug.h" #include "debug.h"
@ -268,6 +271,15 @@ private:
C *_c; M _m; C *_c; M _m;
}; };
/// create std::string from any number
template <typename T>
std::string toString (const T &thing, int w = 0, int p = 0)
{
std::ostringstream os;
os << std::setw(w) << std::setprecision(p) << thing;
return os.str();
}
} /* namespace DBus */ } /* namespace DBus */
#endif//__DBUSXX_UTIL_H #endif//__DBUSXX_UTIL_H

View file

@ -33,6 +33,7 @@
#include <sys/poll.h> #include <sys/poll.h>
#include <dbus/dbus.h> #include <dbus/dbus.h>
#include <errno.h>
using namespace DBus; using namespace DBus;
@ -87,7 +88,10 @@ void BusDispatcher::enter()
void BusDispatcher::leave() void BusDispatcher::leave()
{ {
_running = false; _running = false;
write(_fdunlock[1],"exit",strlen("exit"));
int ret = write(_fdunlock[1],"exit",strlen("exit"));
if (ret == -1) throw Error("WriteError:errno", toString(errno).c_str());
close(_fdunlock[1]); close(_fdunlock[1]);
close(_fdunlock[0]); close(_fdunlock[0]);
} }