[Libevent-users] patch to libevent 1.3e rtsig.c

Phil Budne phil at ultimate.com
Tue May 6 21:52:26 EDT 2008


The ChangeLog file mentioned that rtsig support was removed in 1.40-beta:
    Changes in 1.4.0-beta:
    ....
    o Remove support for the rtsig method: it hasn't compiled for a while ...

With the patch against libevent 1.3e included below, rtsig.c compiles.

I only noticed that RT signals were supported because the 1.4.3 man
page had the (obsolete) note:
    Support for real-time signals is due to Taral.

NOTE!

I have not yet tested it.  A client of mine is looking at converting
an application from RT signals to epoll, and I wanted to benchmark the
performance of the two mechanisms (no paper I've found covers both),
and libevent looked like a good way to test the two head on, and
perhaps the ideal new API to use).

Suggestions on testing/benchmarking methods would be most welcome
(ie; programs/scripts to generate graphs found on the libevent home page)!

Phil

*** rtsig.c.orig	2007-07-30 23:41:04.000000000 -0400
--- rtsig.c	2008-05-06 21:23:00.000000000 -0400
***************
*** 176,190 ****
  #include "event.h"
  #include "event-internal.h"
  #include "log.h"
- extern struct event_list signalqueue;
  
- #include <linux/unistd.h>
  #ifndef __NR_gettid
  #define gettid() getpid()
  #else
- 
  #if ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 3)))
  _syscall0(pid_t,gettid)
  #endif
  
  #endif
--- 176,193 ----
  #include "event.h"
  #include "event-internal.h"
  #include "log.h"
  
  #ifndef __NR_gettid
  #define gettid() getpid()
  #else
  #if ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 3)))
+ #ifdef _syscall0
  _syscall0(pid_t,gettid)
+ #else
+ pid_t gettid(void) {
+     return syscall(__NR_gettid);
+ }
+ #endif
  #endif
  
  #endif
***************
*** 544,550 ****
  } while (0)
  
  void *
! rtsig_init(struct event_base *)
  {
  	struct rtsigop *op;
  	int sockets[2];
--- 547,553 ----
  } while (0)
  
  void *
! rtsig_init(struct event_base *base)
  {
  	struct rtsigop *op;
  	int sockets[2];
***************
*** 866,873 ****
      
  	} else if (sigismember(&op->sigs, signum)) {
  		/* managed signals are queued */
! 		ev = TAILQ_FIRST(&signalqueue);
! 		while (ev != TAILQ_END(&signalqueue)) {
  			next_ev = TAILQ_NEXT(ev, ev_signal_next);
  			if (EVENT_SIGNAL(ev) == signum)
  				activate(ev, EV_SIGNAL);
--- 869,876 ----
      
  	} else if (sigismember(&op->sigs, signum)) {
  		/* managed signals are queued */
! 		ev = TAILQ_FIRST(&base->sig.signalqueue);
! 		while (ev != TAILQ_END(&base->sig.signalqueue)) {
  			next_ev = TAILQ_NEXT(ev, ev_signal_next);
  			if (EVENT_SIGNAL(ev) == signum)
  				activate(ev, EV_SIGNAL);


More information about the Libevent-users mailing list