From: <jpg...@us...> - 2008-07-02 22:49:07
|
Revision: 1448 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1448&view=rev Author: jpgrayson Date: 2008-07-02 15:49:16 -0700 (Wed, 02 Jul 2008) Log Message: ----------- Fix bug where on some linux systems, the user does not have permission to set the priority sufficiently high. Thanks to Jean-Denis for bug report and initial patch. Modified Paths: -------------- trunk/lib/unixfuncs.c Modified: trunk/lib/unixfuncs.c =================================================================== --- trunk/lib/unixfuncs.c 2008-07-02 22:42:26 UTC (rev 1447) +++ trunk/lib/unixfuncs.c 2008-07-02 22:49:16 UTC (rev 1448) @@ -217,20 +217,32 @@ { struct sched_param schp = { 0 }; struct sched_param schat = { 0 }; + int pri = b->priority + 4; /* Run at a priority level above main thread so we can still run if it * hangs. Rise more than 1 because of rumored off-by-one scheduler * bugs. */ - schp.sched_priority = b->priority + 4; - if( schp.sched_priority > b->max_priority ) - schp.sched_priority = b->max_priority; + if ( pri > b->max_priority ) + pri = b->max_priority; - if (pthread_setschedparam(pthread_self(), SCHEDULER_POLICY, &schp) != 0) + for ( ; pri > b->priority; pri-- ) { - ERR_RPT("WatchDogProc: cannot set watch dog priority!\n"); - goto killAudio; + schp.sched_priority = pri; + + if ( pthread_setschedparam(pthread_self(), SCHEDULER_POLICY, + &schp) ) + ERR_RPT("WatchDogProc: cannot set watch dog priority!" + " %d\n", pri); + else + break; } + /* If the watchdog thread cannot get a higher priority than the canary, + * the whole scheme falls apart. Bail. + */ + if ( pri <= b->priority ) + goto killAudio; + DBUG("prioboost: WatchDog priority set to level %d!\n", schp.sched_priority); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |