migrate last clone call(needed to properly handle incoming SMS messages) to pthread
This commit is contained in:
parent
5f63c76d0a
commit
51c8931cbd
@ -7,7 +7,7 @@
|
|||||||
#include "yasnd-log.h"
|
#include "yasnd-log.h"
|
||||||
|
|
||||||
pthread_t ipc_main_handle;
|
pthread_t ipc_main_handle;
|
||||||
pid_t ipc_sms_read_clone_pid=-1; // pid of thread, that checks for new incoming SMS
|
pthread_t ipc_sms_read_handle; // handle of thread, that checks for new incoming SMS
|
||||||
int qid=-1; // IPC queue id
|
int qid=-1; // IPC queue id
|
||||||
|
|
||||||
int open_queue()
|
int open_queue()
|
||||||
@ -107,12 +107,8 @@ void* ipc_queue_loop(void* param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ipc_sms_reading_loop()
|
void* ipc_sms_reading_loop(void* param)
|
||||||
{
|
{
|
||||||
// set default signal handlers
|
|
||||||
signal(SIGTERM,SIG_DFL);
|
|
||||||
signal(SIGHUP,SIG_DFL);
|
|
||||||
//
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
sleep(30); /* wait 30 seconds */
|
sleep(30); /* wait 30 seconds */
|
||||||
@ -131,15 +127,16 @@ void ipc_init()
|
|||||||
log_event("Main IPC event thread creation failed");
|
log_event("Main IPC event thread creation failed");
|
||||||
}
|
}
|
||||||
// start loop, that handles new incoming SMS
|
// start loop, that handles new incoming SMS
|
||||||
unsigned char sms_child_stack[16384];
|
if(pthread_create(&ipc_sms_read_handle,NULL,ipc_sms_reading_loop, NULL) != 0)
|
||||||
ipc_sms_read_clone_pid=clone(ipc_sms_reading_loop,sms_child_stack+8192,CLONE_VM,NULL);
|
{
|
||||||
|
log_event("Failed to create thread for incoming SMS parsing");
|
||||||
|
}
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
void ipc_free()
|
void ipc_free()
|
||||||
{
|
{
|
||||||
pthread_cancel(ipc_main_handle);
|
pthread_cancel(ipc_main_handle);
|
||||||
kill(ipc_sms_read_clone_pid,SIGTERM);
|
pthread_cancel(ipc_sms_read_handle);
|
||||||
waitpid(ipc_sms_read_clone_pid,NULL,__WCLONE);
|
|
||||||
remove_queue(qid);
|
remove_queue(qid);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user