Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 6d02d9f3 authored by deuce's avatar deuce

Switched from using an ODTimer for pascing od_kernel to using a signal

handler and setitimer()
parent aa691df6
......@@ -107,6 +107,9 @@ static void ODKrnlHandleReceivedChar(char chReceived, BOOL bFromRemote);
static void ODKrnlTimeUpdate(void);
static void ODKrnlChatCleanup(void);
static void ODKrnlChatMode(void);
#ifdef ODPLAT_NIX
void sig_run_kernel(int sig);
#endif
/* Functions specific to the multithreaded implementation of the kernel. */
#ifdef OD_MULTITHREADED
......@@ -170,6 +173,8 @@ tODResult ODKrnlInitialize(void)
{
#ifdef ODPLAT_NIX
sigset_t block;
struct sigaction act;
struct itimerval itv;
#endif
tODResult Result = kODRCSuccess;
......@@ -179,6 +184,17 @@ tODResult ODKrnlInitialize(void)
sigemptyset(&block);
sigaddset(&block,SIGHUP);
sigprocmask(SIG_BLOCK,&block,NULL);
/* Run kernel on SIGALRM */
act.sa_handler=sig_run_kernel;
act.sa_flags=0;
sigemptyset(&(act.sa_mask));
sigaction(SIGALRM,&act,NULL);
itv.it_interval.tv_sec=0;
itv.it_interval.tv_usec=250000;
itv.it_value.tv_sec=0;
itv.it_value.tv_usec=250000;
setitimer(ITIMER_REAL,&itv,NULL);
#endif
/* Initialize time of next status update and next time deduction. */
......@@ -1573,3 +1589,18 @@ static void ODKrnlChatCleanup(void)
}
#endif
}
/* ----------------------------------------------------------------------------
* sig_run_kernel(sig) *** PRIVATE FUNCTION ***
*
* Runs od_kernel() on a SIGALRM
*
*/
#ifdef ODPLAT_NIX
void sig_run_kernel(int sig)
{
od_kernel();
}
#endif
......@@ -65,7 +65,11 @@ tODResult ODKrnlStartChatThread(BOOL bTriggeredInternally);
#ifdef OD_MULTITHREADED
#define CALL_KERNEL_IF_NEEDED()
#else /* !OD_MULTITHREADED */
#ifdef ODPLAT_NIX
#define CALL_KERNEL_IF_NEEDED()
#else
#define CALL_KERNEL_IF_NEEDED() od_kernel()
#endif /* !ODPLAT_NIX */
#endif /* !OD_MULTITHREADED */
/* Macro used to increment or decrement OpenDoors active semaphore. */
......
......@@ -615,11 +615,14 @@ BOOL ODTimerElapsed(tODTimer *pTimer)
#endif /* ODPLAT_WIN32 */
#ifdef ODPLAT_NIX
/* Don't bother checking for RunKernelTimer */
if (pTimer==&RunKernelTimer)
return;
tv.tv_sec=0;
tv.tv_usec=1000;
gettimeofday(&tv,NULL);
end.tv_sec=pTimer->Start.tv_sec+(pTimer->Duration / 1000);
end.tv_usec=(pTimer->Start.tv_usec+(pTimer->Duration*1000))%1000000;
gettimeofday(&tv,NULL);
return(end.tv_sec >= tv.tv_sec && end.tv_usec >= tv.tv_usec);
#endif
}
......
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