From 51c8931cbd5b1011fa9f4faa00aa5675a5fd4b22 Mon Sep 17 00:00:00 2001 From: Sergey Popov Date: Fri, 6 Apr 2012 13:25:22 +0400 Subject: [PATCH] migrate last clone call(needed to properly handle incoming SMS messages) to pthread --- daemon/yasnd-ipc.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/daemon/yasnd-ipc.c b/daemon/yasnd-ipc.c index ef5e11d..88dcf42 100644 --- a/daemon/yasnd-ipc.c +++ b/daemon/yasnd-ipc.c @@ -7,7 +7,7 @@ #include "yasnd-log.h" 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 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) { sleep(30); /* wait 30 seconds */ @@ -131,15 +127,16 @@ void ipc_init() log_event("Main IPC event thread creation failed"); } // start loop, that handles new incoming SMS - unsigned char sms_child_stack[16384]; - ipc_sms_read_clone_pid=clone(ipc_sms_reading_loop,sms_child_stack+8192,CLONE_VM,NULL); + if(pthread_create(&ipc_sms_read_handle,NULL,ipc_sms_reading_loop, NULL) != 0) + { + log_event("Failed to create thread for incoming SMS parsing"); + } // } void ipc_free() { pthread_cancel(ipc_main_handle); - kill(ipc_sms_read_clone_pid,SIGTERM); - waitpid(ipc_sms_read_clone_pid,NULL,__WCLONE); + pthread_cancel(ipc_sms_read_handle); remove_queue(qid); }