pDbusDispatchCallback(this, &CAmDbusWrapper::dbusDispatchCallback), //
pDbusFireCallback(this, &CAmDbusWrapper::dbusFireCallback), //
pDbusCheckCallback(this, &CAmDbusWrapper::dbusCheckCallback), //
- pDbusTimerCallback(this, &CAmDbusWrapper::dbusTimerCallback), //
pDbusPrepareCallback(this,&CAmDbusWrapper::dbusPrepareCallback), //
+ pDbusTimerCallback(this, &CAmDbusWrapper::dbusTimerCallback), //
mpDbusConnection(0), //
mDBusError(), //
mListNodes(), //
CAmSocketHandler::CAmSocketHandler() :
receiverCallbackT(this, &CAmSocketHandler::receiverCallback),//
checkerCallbackT(this, &CAmSocketHandler::checkerCallback),//
- mPipe(),
+ mPipe(), //
+ mDispatchDone(1),//
mListPoll(), //
mListTimer(), //
mListActiveTimer(), //
mRecreatePollfds(true), //
mStartTime() //
{
- gDispatchDone = 1;
-
if (pipe(mPipe) == -1)
{
logError("CAmSerializer could not create pipe!");
*/
void CAmSocketHandler::start_listenting()
{
- gDispatchDone = 0;
+ mDispatchDone = 0;
int16_t pollStatus;
//prepare the signalmask
sigaddset(&sigmask, SIGQUIT);
clock_gettime(CLOCK_MONOTONIC, &mStartTime);
- while (!gDispatchDone)
+ while (!mDispatchDone)
{
//first we go through the registered filedescriptors and check if someone needs preparation:
std::for_each(mListPoll.begin(), mListPoll.end(), CAmShCallPrep());
*/
void CAmSocketHandler::stop_listening()
{
- gDispatchDone = 1;
+ mDispatchDone = 1;
//this is for all running timers only - we need to handle the additional offset here
if (!mListActiveTimer.empty())
//we add here the time difference between startTime and currenttime, because this time will be substracted later on in timecorrection
timespec currentTime;
clock_gettime(CLOCK_MONOTONIC, ¤tTime);
- if (!gDispatchDone) //the mainloop is started
+ if (!mDispatchDone) //the mainloop is started
timerItem.countdown = timespecAdd(timeouts, timespecSub(currentTime, mStartTime));
mListActiveTimer.push_back(timerItem);
currentTime.tv_nsec=timeoutsCorrected.tv_nsec=0;
currentTime.tv_sec=timeoutsCorrected.tv_sec=0;
clock_gettime(CLOCK_MONOTONIC, ¤tTime);
- if (!gDispatchDone) //the mainloop is started
+ if (!mDispatchDone) //the mainloop is started
timeoutsCorrected = timespecAdd(timeouts, timespecSub(currentTime, mStartTime));
for (; activeIt != mListActiveTimer.end(); ++activeIt)
//we add here the time difference between startTime and currenttime, because this time will be substracted later on in timecorrection
timespec currentTime, timeoutsCorrected;
clock_gettime(CLOCK_MONOTONIC, ¤tTime);
- if (!gDispatchDone) //the mainloop is started
+ if (!mDispatchDone) //the mainloop is started
{
timeoutsCorrected = timespecAdd(timerItem.countdown, timespecSub(currentTime, mStartTime));
timerItem.countdown = timeoutsCorrected;
#define MAX_NS 1000000000L
-static volatile sig_atomic_t gDispatchDone = 1; //this global is used to stop the mainloop
-
typedef uint16_t sh_timerHandle_t; //!<this is a handle for a timer to be used with the SocketHandler
typedef uint16_t sh_pollHandle_t; //!<this is a handle for a filedescriptor to be used with the SocketHandler
static CAmSocketHandler* mInstance;
int mPipe[2];
-
+ int mDispatchDone; //this starts / stops the mainloop
struct sh_timer_s //!<struct that holds information of timers
{
sh_timerHandle_t handle; //!<the handle of the timer