[Libevent-users] bug with 1.2
Phil Oleson
oz at nixil.net
Tue Nov 14 02:24:24 EST 2006
Niels,
Have you been able to reproduce this yet?
-Phil.
Phil Oleson wrote:
> Hey all,
>
> Yesterday morning I decided to update the freebsd port for
> libevent to 1.2 and send in a pr. Someone previously had bumped it up to
> the 1.2 preview release that Niels had kindly let us play with.
> Anyways.. afterwards I had the motivation to go work on a side project
> of mine that uses libevent. Well it started failing with the new
> install. I've stripped down a simple case that uses timers (which
> triggers the problem), from a larger program (attached). Can I get
> others to try this out and see if they get invalid similar to this?
>
> export -n NOKQUEUE
> ~/test> ./test-failure
> [warn] kevent: Invalid argument
> ~/test> export EVENT_NOKQUEUE=1
> ~/test> ./test-failure
> [warn] poll: Invalid argument
> ~/test> export EVENT_NOPOLL=1
> ~/test> ./test-failure
> [warn] select: Invalid argument
>
> Thanks..
>
> -Phil.
>
>
> ------------------------------------------------------------------------
>
> #include <stdio.h>
> #include <sys/time.h>
> #include <event.h>
>
> #define OPT_USEC 125000
>
> void
> iteration(int fd, short event, void *arg)
> {
> struct event *tev = (struct event *)arg;
> struct timeval start, end, nextloop, delay;
> static struct timeval sleep_tv = { 0, OPT_USEC };
> int i;
>
> /* figure out when the next iteration should trigger */
> gettimeofday(&start, (struct timezone *) 0);
> timeradd(&start, &sleep_tv, &nextloop);
>
> /* do something here */
> for( i = 0; i < 10; ++i )
> {
> fprintf( stderr, "Test %d\n", i );
> }
>
> /* subtract time it took to do the above from the sleep time */
> gettimeofday(&end, (struct timezone *) 0);
> timersub(&nextloop, &end, &delay);
>
> /* setup next iteration */
> evtimer_add(tev, &delay);
> }
>
> int
> main(int argc, char **argv)
> {
> struct timeval tvt, sleep_tv = { 0, OPT_USEC };
> struct event tev;
>
> /* setup the event system */
> event_init();
>
> /* Setup the initial game_iteration pass */
> gettimeofday(&tvt, (struct timezone *) 0);
> timeradd(&tvt, &sleep_tv, &tvt);
>
> evtimer_set(&tev, iteration, &tev);
> evtimer_add(&tev, &tvt);
>
> /* main control loop for the program */
> event_dispatch();
> }
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Libevent-users mailing list
> Libevent-users at monkey.org
> http://monkey.org/mailman/listinfo/libevent-users
More information about the Libevent-users
mailing list