Commit 9d02679e by Baruch Sterin

fixes for dumb erros in utilSignal.c/h

parent a7e214bb
...@@ -50,14 +50,17 @@ struct Hash_Gen_Entry_t_ ...@@ -50,14 +50,17 @@ struct Hash_Gen_Entry_t_
struct Hash_Gen_Entry_t_ * pNext; struct Hash_Gen_Entry_t_ * pNext;
}; };
typedef int (*Hash_GenHashFunction_t)(void* key, int nBins);
typedef int (*Hash_GenCompFunction_t)(void* key, void* data);
struct Hash_Gen_t_ struct Hash_Gen_t_
{ {
int nSize; int nSize;
int nBins; int nBins;
int (* fHash)(void *key, int nBins); Hash_GenHashFunction_t fHash;
int (* fComp)(void *key, void *data); Hash_GenCompFunction_t fComp;
int fFreeKey; int fFreeKey;
Hash_Gen_Entry_t ** pArray; Hash_Gen_Entry_t ** pArray;
}; };
......
...@@ -41,7 +41,7 @@ ABC_NAMESPACE_IMPL_START ...@@ -41,7 +41,7 @@ ABC_NAMESPACE_IMPL_START
static Hash_Gen_t* watched_pid_hash = NULL; static Hash_Gen_t* watched_pid_hash = NULL;
static Hash_Gen_t* watched_tmp_files_hash = NULL; static Hash_Gen_t* watched_tmp_files_hash = NULL;
static sigset_t* old_procmask; static sigset_t old_procmask;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -67,8 +67,8 @@ void Util_SignalCleanup() ...@@ -67,8 +67,8 @@ void Util_SignalCleanup()
// kill all watched child processes // kill all watched child processes
Hash_GenForEachEntry(watched_pid_hash, pEntry, i) Hash_GenForEachEntry(watched_pid_hash, pEntry, i)
{ {
pid_t pid = (pid_t)pEntry->key; pid_t pid = (pid_t)(ABC_PTRINT_T)pEntry->key;
pid_t ppid = (pid_t)pEntry->data; pid_t ppid = (pid_t)(ABC_PTRINT_T)pEntry->data;
if (getpid() == ppid) if (getpid() == ppid)
{ {
...@@ -79,8 +79,8 @@ void Util_SignalCleanup() ...@@ -79,8 +79,8 @@ void Util_SignalCleanup()
// remove watched temporary files // remove watched temporary files
Hash_GenForEachEntry(watched_tmp_files_hash, pEntry, i) Hash_GenForEachEntry(watched_tmp_files_hash, pEntry, i)
{ {
int fname = (const char*)pEntry->key; const char* fname = (const char*)pEntry->key;
pid_t ppid = (pid_t)pEntry->data; pid_t ppid = (pid_t)(ABC_PTRINT_T)pEntry->data;
if( getpid() == ppid ) if( getpid() == ppid )
{ {
...@@ -104,7 +104,7 @@ void Util_SignalCleanup() ...@@ -104,7 +104,7 @@ void Util_SignalCleanup()
void Util_SignalStartHandler() void Util_SignalStartHandler()
{ {
watched_pid_hash = Hash_GenAlloc(100, Hash_DefaultHashFuncInt, Hash_DefaultCmpFuncInt, 0); watched_pid_hash = Hash_GenAlloc(100, Hash_DefaultHashFuncInt, Hash_DefaultCmpFuncInt, 0);
watched_tmp_files_hash = Hash_GenAlloc(100, Hash_DefaultHashFuncStr, strcmp, 1); watched_tmp_files_hash = Hash_GenAlloc(100, Hash_DefaultHashFuncStr, (Hash_GenCompFunction_t)strcmp, 1);
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -121,9 +121,6 @@ void Util_SignalStartHandler() ...@@ -121,9 +121,6 @@ void Util_SignalStartHandler()
void Util_SignalResetHandler() void Util_SignalResetHandler()
{ {
int i;
Hash_Gen_Entry_t* pEntry;
sigset_t procmask, old_procmask; sigset_t procmask, old_procmask;
sigemptyset(&procmask); sigemptyset(&procmask);
...@@ -135,16 +132,13 @@ void Util_SignalResetHandler() ...@@ -135,16 +132,13 @@ void Util_SignalResetHandler()
watched_pid_hash = Hash_GenAlloc(100, Hash_DefaultHashFuncInt, Hash_DefaultCmpFuncInt, 0); watched_pid_hash = Hash_GenAlloc(100, Hash_DefaultHashFuncInt, Hash_DefaultCmpFuncInt, 0);
Hash_GenFree(watched_tmp_files_hash); Hash_GenFree(watched_tmp_files_hash);
watched_tmp_files_hash = Hash_GenAlloc(100, Hash_DefaultHashFuncStr, strcmp, 1); watched_tmp_files_hash = Hash_GenAlloc(100, Hash_DefaultHashFuncStr, (Hash_GenCompFunction_t)strcmp, 1);
sigprocmask(SIG_SETMASK, &old_procmask, NULL); sigprocmask(SIG_SETMASK, &old_procmask, NULL);
} }
void Util_SignalStopHandler() void Util_SignalStopHandler()
{ {
int i;
Hash_Gen_Entry_t* pEntry;
Hash_GenFree(watched_pid_hash); Hash_GenFree(watched_pid_hash);
watched_pid_hash = NULL; watched_pid_hash = NULL;
...@@ -213,9 +207,9 @@ static void unwatch_tmp_file(const char* fname) ...@@ -213,9 +207,9 @@ static void unwatch_tmp_file(const char* fname)
{ {
if ( watched_tmp_files_hash ) if ( watched_tmp_files_hash )
{ {
assert( Hash_GenExists(watched_tmp_files_hash, fname) ); assert( Hash_GenExists(watched_tmp_files_hash, (void*)fname) );
Hash_GenRemove(watched_tmp_files_hash, fname); Hash_GenRemove(watched_tmp_files_hash, (void*)fname);
assert( !Hash_GenExists(watched_tmp_files_hash, fname) ); assert( !Hash_GenExists(watched_tmp_files_hash, (void*)fname) );
} }
} }
...@@ -260,9 +254,8 @@ void Util_SignalRemoveChildPid(int pid) ...@@ -260,9 +254,8 @@ void Util_SignalRemoveChildPid(int pid)
} }
// a dummy signal hanlder to make sure that SIGCHLD and SIGINT will cause sigsuspend() to return // a dummy signal hanlder to make sure that SIGCHLD and SIGINT will cause sigsuspend() to return
static int null_sig_handler(int signum) static void null_sig_handler(int signum)
{ {
return 0;
} }
...@@ -278,7 +271,7 @@ static void replace_sighandler(int signum, struct sigaction* old_sa, int replace ...@@ -278,7 +271,7 @@ static void replace_sighandler(int signum, struct sigaction* old_sa, int replace
sa.sa_handler = null_sig_handler; sa.sa_handler = null_sig_handler;
sigaction(signum, &sa, &old_sa); sigaction(signum, &sa, old_sa);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment