Index: ossp-pkg/l2/configure.ac RCS File: /v/ossp/cvs/ossp-pkg/l2/configure.ac,v rcsdiff -q -kk '-r1.11' '-r1.12' -u '/v/ossp/cvs/ossp-pkg/l2/configure.ac,v' 2>/dev/null --- configure.ac 2001/10/06 14:33:09 1.11 +++ configure.ac 2001/10/12 14:46:16 1.12 @@ -81,7 +81,7 @@ fi AC_CHECK_LIB(socket, accept) -AC_CHECK_FUNCS(inet_aton inet_pton inet_ntoa inet_ntop snprintf vsnprintf) +AC_CHECK_FUNCS(inet_aton inet_pton inet_ntoa inet_ntop snprintf vsnprintf setitimer) sinclude(l2_ut_sa.ac) AC_CHECK_SA Index: ossp-pkg/l2/l2_ch_buffer.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_ch_buffer.c,v rcsdiff -q -kk '-r1.23' '-r1.24' -u '/v/ossp/cvs/ossp-pkg/l2/l2_ch_buffer.c,v' 2>/dev/null --- l2_ch_buffer.c 2001/10/05 14:25:57 1.23 +++ l2_ch_buffer.c 2001/10/12 14:46:17 1.24 @@ -28,11 +28,13 @@ */ #include "l2.h" -#include "l2_p.h" /* for TRACE() */ +#include "l2_p.h" /* for TRACE() */ #include -#include /* has setitime() in standard unix functions */ -#include /* for use of sigaction() and SIGALRM */ +#include /* for alarm() and setitime() */ +#include /* for use of sigaction() and SIGALRM */ + +#define L2_BUFFER_TIMER ITIMER_REAL /* calls to [s|g]etitimer() and alarm() */ /* declare private channel configuration */ typedef struct { @@ -41,7 +43,9 @@ int bufsize; int bufinterval; struct sigaction sigalrm; +#ifdef HAVE_SETITIMER struct itimerval valprev; +#endif int levelflush; l2_level_t level; } l2_ch_buffer_t; @@ -79,7 +83,9 @@ cfg->levelflush = 0; cfg->level = L2_LEVEL_NONE; memset(&cfg->sigalrm, 0, sizeof(cfg->sigalrm)); +#ifdef HAVE_SETITIMER memset(&cfg->valprev, 0, sizeof(cfg->valprev)); +#endif /* link private channel configuration into channel context */ ctx->vp = cfg; @@ -112,6 +118,7 @@ ************************************************************/ static int set_alarm(l2_ch_buffer_t *cfg) { +#ifdef HAVE_INET_SETITIMER struct itimerval valnew; /* initialize auto vars before using them */ @@ -121,7 +128,10 @@ valnew.it_interval.tv_usec = 0; valnew.it_value.tv_sec = cfg->bufinterval; valnew.it_value.tv_usec = 0; - return setitimer(ITIMER_REAL, &valnew, &cfg->valprev); /* set flush timer */ + return setitimer(L2_BUFFER_TIMER, &valnew, &cfg->valprev); +#else + return 0; +#endif } /************************************************************ @@ -130,6 +140,7 @@ ************************************************************/ static int reset_alarm(l2_ch_buffer_t *cfg) { +#ifdef HAVE_INET_SETITIMER struct itimerval valnew; /* initialize auto vars before using them */ @@ -139,7 +150,10 @@ valnew.it_interval.tv_usec = 0; valnew.it_value.tv_sec = cfg->bufinterval; valnew.it_value.tv_usec = 0; - return setitimer(ITIMER_REAL, &valnew, 0); /* reset flush timer */ + return setitimer(L2_BUFFER_TIMER, &valnew, 0); +#else + return 0; +#endif } /* open channel */ @@ -256,8 +270,13 @@ l2_result_t rv; if (cfg->bufinterval != 0) { - setitimer(ITIMER_REAL, &cfg->valprev, 0); /* restore timer values */ - /* restore previous signal context if previously saved & replaced */ +#ifdef HAVE_INET_SETITIMER + if (setitimer(L2_BUFFER_TIMER, &cfg->valprev, 0)) /* restore timer */ + return L2_ERR_SYS; +#else + alarm(0); +#endif + /* restore previous signal context if previously saved & replaced */ if (&cfg->sigalrm.sa_handler) if (sigaction(SIGALRM, &cfg->sigalrm, 0) < 0) rv = L2_ERR_SYS;