- Realtime Scheduling for RTP proxy

This commit is contained in:
Thomas Ries 2004-04-04 14:22:00 +00:00
parent b98a0f08f0
commit f409950b8e
4 changed files with 47 additions and 1 deletions

View File

@ -1,5 +1,6 @@
0.5.5
=====
4-Apr-2004: - Realtime Scheduling for RTP proxy
3-Apr-2004: - fix: SDP 'c=' items in media part
2-Apr-2004: - PID file
31-Mar-2004: - accessctl.c: text correction in ERROR output

View File

@ -84,12 +84,21 @@
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
/* Define to 1 if you have the `pthread_setschedparam' function. */
#undef HAVE_PTHREAD_SETSCHEDPARAM
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
/* Define to 1 if you have the `read' function. */
#undef HAVE_READ
/* Define to 1 if you have the `sched_get_priority_max' function. */
#undef HAVE_SCHED_GET_PRIORITY_MAX
/* Define to 1 if you have the `sched_get_priority_min' function. */
#undef HAVE_SCHED_GET_PRIORITY_MIN
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT

View File

@ -335,6 +335,9 @@ AC_CHECK_FUNCS(hstrerror,,AC_CHECK_LIB(resolv,hstrerror,[
AC_DEFINE_UNQUOTED(HAVE_HSTRERROR)
LIBS="$LIBS -lresolv"]))
AC_CHECK_FUNCS(inet_pton inet_ntop inet_aton inet_ntoa)
AC_CHECK_FUNCS(pthread_setschedparam sched_get_priority_min)
AC_CHECK_FUNCS(sched_get_priority_max)
dnl

View File

@ -9,7 +9,7 @@
(at your option) any later version.
Siproxd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warrantry of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@ -32,6 +32,10 @@
#include <netinet/in.h>
#include <signal.h>
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
#include <sched.h>
#endif
#include <osipparser2/osip_parser.h>
#include "siproxd.h"
@ -103,6 +107,35 @@ int rtp_relay_init( void ) {
sts=pthread_create(&rtpproxy_tid, NULL, rtpproxy_main, (void *)&arg);
DEBUGC(DBCLASS_RTP,"created, sts=%i", sts);
/* set realtime scheduling - if started by root */
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
{
int uid,euid;
struct sched_param schedparam;
uid=getuid();
euid=geteuid();
if (uid != euid) seteuid(0);
if (geteuid()==0) {
int pmin, pmax;
/* place ourself at 1/3 of the available priority space */
pmin=sched_get_priority_min(SCHED_RR);
pmax=sched_get_priority_max(SCHED_RR);
schedparam.sched_priority=pmin+(pmax-pmin)/3;
DEBUGC(DBCLASS_RTP,"pmin=%i, pmax=%i, using p=%i", pmin, pmax,
schedparam.sched_priority);
sts=pthread_setschedparam(rtpproxy_tid, SCHED_RR, &schedparam);
if (sts != 0) {
ERROR("pthread_setschedparam failed: %s", strerror(errno));
}
} else {
WARN("Cannot set realtime scheduling for RTP (start siproxd as root)");
}
if (uid != euid) seteuid(euid);
}
#endif
return STS_SUCCESS;
}