[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Timeout Event Not Working?
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] Timeout Event Not Working?
- From: Donghua Xu <donghua@xxxxxxxxx>
- Date: Fri, 29 Jan 2010 02:19:13 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Fri, 29 Jan 2010 02:19:18 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=mStIdUsMYPEc7i/P6gje6t01Op5VckVB81n7EZYR/dM=; b=hsPjQ9SbMyObTYZtdeWvV6iL7evF9hP9kLoYMLKa6UAgr5O8bxlsJqLBOcUJy8av9S 3/FiIPQV458SxI5WkM3dg5YS10FTIiWhoGr7qd9htrRDN/5zYN/GsgjcMLR1T5b1YboS Zv84Cej0zWWfw8c3MDkVahZaeA4+ByMjFzaQs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=jbDnapKnwKzJWqntBlFd9E9Yrkj5yxJ0P3q5MlAoVN0d0ocEhKpHnrv1JMKliFOTim WLwQj00LO/Sj9LV25uBENXrTB/DOQ3sjkou5gMhye44a5NfP0wC6rnTo+aNadWC3MF6E /vc0KgIrNdVN2hZ3ZEvlKKyk3VxhkakRmPks4=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hi, I just wrote a simple program trying to use the timeout event in libevent 2.0.3-alpha. The source code is at the end of the email. I'm expecting to see a print out of "***in dummy_callback()", but this line does not show up at all. What I am seeing is only:
***entering main()
***entering EventLoop()
***dummy_event=0x60e690
***exiting EventLoop()
***exiting main()
What am I doing wrong in the following source code? A lot of thanks in advance...
#include <stdlib.h>
#include <stdio.h>
#include "event2/event.h"
struct event_base *global_event_base;
static void dummy_callback(evutil_socket_t fd, short what, void *arg)
{
printf("***in dummy_callback()\n");
}
static void* EventLoop(void *arg)
{
printf("***entering EventLoop()\n");
global_event_base = event_base_new();
if (!global_event_base) {
printf("event_base_new() failed\n");
exit (-1);
}
struct timeval five_seconds = {5,0};
struct event *dummy_event =
evtimer_new(global_event_base, dummy_callback, arg);
printf("***dummy_event=%p\n", dummy_event);
event_add(dummy_event, &five_seconds);
int ret = event_base_loop(global_event_base, EVLOOP_NONBLOCK);
if (ret!=0)
printf("event_base_loop() failed\n");
printf("***exiting EventLoop()\n");
return NULL;
}
int main()
{
printf("***entering main()\n");
EventLoop(NULL);
printf("***exiting main()\n");
fflush(stdout);
return 0;
}