BugFix: stop Process mechanism of ProcessFramework.

Update: DISCONNECT procedure for NonActive clients.

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2016-10-04 11:17:46 +09:00
parent 93df7db12e
commit 63d2824444
21 changed files with 338 additions and 239 deletions

View File

@@ -160,12 +160,11 @@ Semaphore::Semaphore(const char* name, unsigned int val)
{
throw Exception( -1, "Semaphore can't be created.");
}
_name = (char*) calloc(strlen(name + 1), 1);
_name = strdup(name);
if (_name == NULL)
{
throw Exception( -1, "Semaphore can't allocate memories.");
}
_name = strdup(name);
}
Semaphore::~Semaphore()
@@ -174,7 +173,7 @@ Semaphore::~Semaphore()
{
sem_close(_psem);
sem_unlink(_name);
free((void*) _name);
free(_name);
}
else
{
@@ -243,12 +242,18 @@ RingBuffer::RingBuffer(const char* keyDirectory)
{
int fp = 0;
string fileName = keyDirectory + string(MQTTSNGW_RINGBUFFER_KEY);
fp = open(fileName.c_str(), O_CREAT, 0);
close(fp);
fp = open(fileName.c_str(), O_CREAT, S_IRGRP);
if ( fp > 0 )
{
close(fp);
}
fileName = keyDirectory + string(MQTTSNGW_RB_MUTEX_KEY);
fp = open(fileName.c_str(), O_CREAT, 0);
close(fp);
fp = open(fileName.c_str(), O_CREAT, S_IRGRP);
if ( fp > 0 )
{
close(fp);
}
key_t key = ftok(MQTTSNGW_RINGBUFFER_KEY, 1);
@@ -302,10 +307,6 @@ RingBuffer::~RingBuffer()
{
shmctl(_shmid, IPC_RMID, NULL);
}
if (_pmx > 0)
{
delete _pmx;
}
}
else
{
@@ -314,6 +315,11 @@ RingBuffer::~RingBuffer()
shmdt(_shmaddr);
}
}
if (_pmx > 0)
{
delete _pmx;
}
}
void RingBuffer::put(char* data)
@@ -469,14 +475,11 @@ void RingBuffer::reset()
=====================================*/
Thread::Thread()
{
_stopProcessEvent = theMultiTaskProcess->getStopProcessEvent();
_threadID = 0;
}
Thread::~Thread()
{
pthread_cancel(_threadID);
pthread_join(_threadID, 0);
}
void* Thread::_run(void* runnable)
@@ -508,10 +511,6 @@ int Thread::start(void)
void Thread::stopProcess(void)
{
_stopProcessEvent->post();
theMultiTaskProcess->threadStoped();
}
void Thread::cancel(void)
{
pthread_cancel(_threadID);
}