I'm not an expert either. :-)

The attached diff is against rsyslog 5.6.2, it also checks for
sched_get_priority_max() which can be used to check the proper priority
range for a given policy.

I've tested the patch on Linux and Solaris. Seems to work fine on both.

Rainer Gerhards wrote:
> I just committed the functionality:
> 
> http://git.adiscon.com/?p=rsyslog.git;a=commitdiff;h=cc8237736d11b54a3d6089d8
> 36da7ccb6972a29c
> 
> Note that I am far from being an autotools expert, so I would appreciate if
> you could provide proper configure checks. I did only a very rough test of
> the functionality.
> 
> Thanks,
> Rainer
> 
> > -----Original Message-----
> > From: [email protected] [mailto:rsyslog-
> > [email protected]] On Behalf Of Dražen Kacar
> > Sent: Thursday, December 16, 2010 10:48 PM
> > To: rsyslog-users
> > Subject: Re: [rsyslog] Losing UDP packages
> > 
> > Rainer Gerhards wrote:
> > > > I suppose it can be done, but pthread_setschedparam(pthread_self(),
> > > > SCHED_FIFO, ...) is portable, simpler and better for my purposes.
> > Also
> > > > slightly dangerous, if one doesn't have enough processors for all
> > RT
> > > > threads. :-)
> > >
> > >
> > > If that's all that is needed, I could very probably hack this
> > together while
> > > I wait for a longer running test...
> > 
> > There are two parameters needed:
> > 1. policy: probably a string that maps to SCHED_xxx, ie:
> >    fifo  => SCHED_FIFO
> >    rr    => SCHED_RR
> >    other => SCHED_OTHER
> > 
> > The code for those mappings should probably be in the appropriate
> > "#ifdef SCHED_xxx" guards. They should be defined if
> > pthread_setschedparam() is available, but you never know.
> > 
> > Ignore SCHED_SPORADIC for the time being.
> > 
> > 2. priority (integer), goes into the third argument for
> >    pthread_setschedparam().
> > 
> > Without defaults for any of these parameters. If one of them is
> > specified
> > in the config file and the other is not, report an error.
> > 
> > Add a configure check (it's possible you'd need -lrt or something
> > similar),
> > and that's about that.
> > 
> > --
> >  .-.   .-.    Yes, I am an agent of Satan, but my duties are largely
> > (_  \ /  _)   ceremonial.
> >      |
> >      |        [email protected]
> > _______________________________________________
> > rsyslog mailing list
> > http://lists.adiscon.net/mailman/listinfo/rsyslog
> > http://www.rsyslog.com
> _______________________________________________
> rsyslog mailing list
> http://lists.adiscon.net/mailman/listinfo/rsyslog
> http://www.rsyslog.com

-- 
 .-.   .-.    Yes, I am an agent of Satan, but my duties are largely
(_  \ /  _)   ceremonial.
     |
     |        [email protected]
--- configure.ac.orig	2010-12-17 14:58:45.000000000 +0100
+++ configure.ac	2010-12-17 16:12:19.000000000 +0100
@@ -269,6 +269,33 @@
   )
 fi
 
+AC_CHECK_FUNCS(
+    [pthread_setschedparam],
+    [
+      rsyslog_have_pthread_setschedparam=yes
+    ],
+    [
+      rsyslog_have_pthread_setschedparam=no
+    ]
+)
+AC_CHECK_HEADERS(
+    [sched.h],
+    [
+      rsyslog_have_sched_h=yes
+    ],
+    [
+      rsyslog_have_sched_h=no
+    ]
+)
+if test "$rsyslog_have_pthread_setschedparam" = "yes" -a "$rsyslog_have_sched_h" = "yes"; then
+	save_LIBS=$LIBS
+	LIBS=
+	AC_SEARCH_LIBS(sched_get_priority_max, rt)
+	IMUDP_LIBS=$LIBS
+	AC_SUBST(IMUDP_LIBS)
+	LIBS=$save_LIBS
+fi
+
 
 # klog
 AC_ARG_ENABLE(klog,
--- config.h.in.orig	2010-12-17 16:02:54.000000000 +0100
+++ config.h.in	2010-12-17 16:04:03.000000000 +0100
@@ -79,6 +79,12 @@
 /* Define to 1 if you have the `gettimeofday' function. */
 #undef HAVE_GETTIMEOFDAY
 
+/* Define to 1 if you have the `pthread_setschedparam' function. */
+#undef HAVE_PTHREAD_SETSCHEDPARAM
+
+/* Define to 1 if you have the <sched.h> file. */
+#undef HAVE_SCHED_H
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
--- plugins/imudp/Makefile.am.orig	2010-12-17 15:02:14.000000000 +0100
+++ plugins/imudp/Makefile.am	2010-12-17 15:02:33.000000000 +0100
@@ -3,4 +3,4 @@
 imudp_la_SOURCES = imudp.c
 imudp_la_CPPFLAGS = -I$(top_srcdir) $(PTHREADS_CFLAGS) $(RSRT_CFLAGS)
 imudp_la_LDFLAGS = -module -avoid-version
-imudp_la_LIBADD = 
+imudp_la_LIBADD = $(IMUDP_LIBS)
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com

Reply via email to