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 b2452bfc authored by deuce's avatar deuce

Change od_sleep() behaviour to select STDIN then call od_kernel() if there

is data waiting.

od_kernel is now ran once every second rather than every 250 ms (One second
granularity is fine for all other kernel tasks afaik)
parent 6d02d9f3
......@@ -304,6 +304,10 @@ tODResult ODInQueueGetNextEvent(tODInQueueHandle hInQueue,
tODInputEvent *pEvent, tODMilliSec Timeout)
{
tInputQueueInfo *pInputQueueInfo = ODHANDLE2PTR(hInQueue, tInputQueueInfo);
#ifdef ODPLAT_NIX
struct timeval tv;
fd_set in;
#endif
ASSERT(pInputQueueInfo != NULL);
ASSERT(pEvent != NULL);
......
......@@ -185,13 +185,13 @@ tODResult ODKrnlInitialize(void)
sigaddset(&block,SIGHUP);
sigprocmask(SIG_BLOCK,&block,NULL);
/* Run kernel on SIGALRM */
/* Run kernel on SIGALRM (Every 1 second) */
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_interval.tv_sec=1;
itv.it_interval.tv_usec=0;
itv.it_value.tv_sec=0;
itv.it_value.tv_usec=250000;
setitimer(ITIMER_REAL,&itv,NULL);
......
......@@ -779,6 +779,7 @@ ODAPIDEF void ODCALL od_sleep(tODMilliSec Milliseconds)
{
#ifdef ODPLAT_NIX
struct timeval tv;
fd_set in;
#endif
/* Log function entry if running in trace mode. */
TRACE(TRACE_API, "od_sleep()");
......@@ -810,13 +811,16 @@ ODAPIDEF void ODCALL od_sleep(tODMilliSec Milliseconds)
#endif /* ODPLAT_WIN32 */
#ifdef ODPLAT_NIX
/* Prevent 100% CPU usage! */
if(Milliseconds==0)
Milliseconds=1;
FD_ZERO(&in);
tv.tv_sec=Milliseconds/1000;
tv.tv_usec=(Milliseconds%1000)*1000;
select(0,NULL,NULL,NULL,&tv);
if(Milliseconds==0) {
tv.tv_usec=1000;
FD_SET(1,&in);
}
if(select(2,Milliseconds?NULL:&in,NULL,NULL,&tv)>0)
od_kernel();
#endif
OD_API_EXIT();
......
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