SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
Submitted By: zephyrus ( zephyrus00jp ) Obs by Marcelo: The issue with linking with -lsocket -lnsl -lrt is not covered in this changeset beacuse I don't have solaris to test. I will need some help from zephyrus in this regard. The issue will be addressed in a future changeset. Compilation for solaris I have used gcc3.x and gcc4.x under solaris 10 for x86 / 64 bits. A couple of Source file fixes were necessary for successful compilation and runtime behavior. threadutil/src/ThreadPool.c POSIX sched_setschduler() returns non-negative value for success. Without the fix, UpnpInit() fails immediately. upnpp/src/api/upnpai.c There is a typo of a macro name "__sun" in one of the CPP conditional. Without the fix, the compilation aborts due to unknown constant in socket ioctl call. A few structs and an array is not properly initialized. Well, I think it may be safe as is, but when I checked it using purify evaluation version, it was reported that uninitizlied iszBuffer may cause read of uninitialized memory. So play it safe. Configure issue. This has to be more of a configure magic. To link a program successfully using network, we need -lsocket and -lnsl library specifications on the link line. We also need -lrt for programs that use thread scheduling features. The sample program under upnp/sample requires -lsocket -lnsl -lrt for successful linking. I added -lsocket -lnsl -lrt to Makefile.in. configure probably needs to take care of these. I don't know much about configure, automake, etc., so I am just raising a flag here. TIA git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@505 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
52
ChangeLog
52
ChangeLog
@@ -2,6 +2,58 @@
|
|||||||
Version 1.6.7
|
Version 1.6.7
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
|
||||||
|
Submitted By: zephyrus ( zephyrus00jp )
|
||||||
|
Obs by Marcelo: The issue with linking with -lsocket -lnsl -lrt is not
|
||||||
|
covered in this changeset beacuse I don't have solaris to test. I will
|
||||||
|
need some help from zephyrus in this regard. The issue will be addressed
|
||||||
|
in a future changeset.
|
||||||
|
|
||||||
|
Compilation for solaris
|
||||||
|
|
||||||
|
I have used gcc3.x and gcc4.x under solaris 10 for x86 / 64 bits.
|
||||||
|
|
||||||
|
A couple of Source file fixes were necessary for successful compilation
|
||||||
|
and runtime behavior.
|
||||||
|
|
||||||
|
threadutil/src/ThreadPool.c
|
||||||
|
|
||||||
|
POSIX
|
||||||
|
sched_setschduler() returns non-negative value for success.
|
||||||
|
|
||||||
|
Without the fix, UpnpInit() fails immediately.
|
||||||
|
|
||||||
|
upnpp/src/api/upnpai.c
|
||||||
|
|
||||||
|
There is a typo of a macro name "__sun" in one of the
|
||||||
|
CPP conditional.
|
||||||
|
Without the fix, the compilation aborts due to unknown constant
|
||||||
|
in socket ioctl call.
|
||||||
|
|
||||||
|
A few structs and an array is not properly initialized.
|
||||||
|
Well, I think it may be safe as is, but when I checked it
|
||||||
|
using purify evaluation version, it was reported that
|
||||||
|
uninitizlied iszBuffer may cause read of uninitialized memory.
|
||||||
|
So play it safe.
|
||||||
|
|
||||||
|
Configure issue.
|
||||||
|
This has to be more of a configure magic.
|
||||||
|
To link a program successfully using network, we need
|
||||||
|
-lsocket and -lnsl library specifications on the link line.
|
||||||
|
We also need -lrt for programs that use thread scheduling features.
|
||||||
|
|
||||||
|
The sample program under upnp/sample requires
|
||||||
|
-lsocket -lnsl -lrt
|
||||||
|
for successful linking.
|
||||||
|
I added -lsocket -lnsl -lrt to Makefile.in.
|
||||||
|
configure probably needs to take care of these.
|
||||||
|
|
||||||
|
I don't know much about configure, automake, etc., so
|
||||||
|
I am just raising a flag here.
|
||||||
|
|
||||||
|
TIA
|
||||||
|
|
||||||
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* SF Patch Tracker [ 2836704 ] Search for nested serviceList (not
|
* SF Patch Tracker [ 2836704 ] Search for nested serviceList (not
|
||||||
stopping at the first lis
|
stopping at the first lis
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* - Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
#include "ThreadPool.h"
|
#include "ThreadPool.h"
|
||||||
#include "FreeList.h"
|
#include "FreeList.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h> /* for memset()*/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: DiffMillis
|
* Function: DiffMillis
|
||||||
@@ -49,12 +49,12 @@
|
|||||||
* Returns:
|
* Returns:
|
||||||
* the difference in milliseconds, time1-time2.
|
* the difference in milliseconds, time1-time2.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static unsigned long DiffMillis( struct timeval *time1, struct timeval *time2 )
|
static unsigned long DiffMillis(struct timeval *time1, struct timeval *time2)
|
||||||
{
|
{
|
||||||
double temp = 0;
|
double temp = 0;
|
||||||
|
|
||||||
assert( time1 != NULL );
|
assert(time1 != NULL);
|
||||||
assert( time2 != NULL );
|
assert(time2 != NULL);
|
||||||
|
|
||||||
temp = time1->tv_sec - time2->tv_sec;
|
temp = time1->tv_sec - time2->tv_sec;
|
||||||
/* convert to milliseconds */
|
/* convert to milliseconds */
|
||||||
@@ -77,9 +77,9 @@ static unsigned long DiffMillis( struct timeval *time1, struct timeval *time2 )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* ThreadPoolStats *stats must be valid non null stats structure
|
* ThreadPoolStats *stats must be valid non null stats structure
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static void StatsInit( ThreadPoolStats *stats )
|
static void StatsInit(ThreadPoolStats *stats)
|
||||||
{
|
{
|
||||||
assert( stats != NULL );
|
assert(stats != NULL);
|
||||||
|
|
||||||
stats->totalIdleTime = 0;
|
stats->totalIdleTime = 0;
|
||||||
stats->totalJobsHQ = 0;
|
stats->totalJobsHQ = 0;
|
||||||
@@ -99,19 +99,19 @@ static void StatsInit( ThreadPoolStats *stats )
|
|||||||
stats->maxThreads = 0; stats->totalThreads = 0;
|
stats->maxThreads = 0; stats->totalThreads = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StatsAccountLQ( ThreadPool *tp, unsigned long diffTime )
|
static void StatsAccountLQ(ThreadPool *tp, unsigned long diffTime)
|
||||||
{
|
{
|
||||||
tp->stats.totalJobsLQ++;
|
tp->stats.totalJobsLQ++;
|
||||||
tp->stats.totalTimeLQ += diffTime;
|
tp->stats.totalTimeLQ += diffTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StatsAccountMQ( ThreadPool *tp, unsigned long diffTime )
|
static void StatsAccountMQ(ThreadPool *tp, unsigned long diffTime)
|
||||||
{
|
{
|
||||||
tp->stats.totalJobsMQ++;
|
tp->stats.totalJobsMQ++;
|
||||||
tp->stats.totalTimeMQ += diffTime;
|
tp->stats.totalTimeMQ += diffTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StatsAccountHQ( ThreadPool *tp, unsigned long diffTime )
|
static void StatsAccountHQ(ThreadPool *tp, unsigned long diffTime)
|
||||||
{
|
{
|
||||||
tp->stats.totalJobsHQ++;
|
tp->stats.totalJobsHQ++;
|
||||||
tp->stats.totalTimeHQ += diffTime;
|
tp->stats.totalTimeHQ += diffTime;
|
||||||
@@ -131,36 +131,36 @@ static void StatsAccountHQ( ThreadPool *tp, unsigned long diffTime )
|
|||||||
* ThreadPriority p
|
* ThreadPriority p
|
||||||
* ThreadPoolJob *job
|
* ThreadPoolJob *job
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static void CalcWaitTime( ThreadPool *tp, ThreadPriority p, ThreadPoolJob *job )
|
static void CalcWaitTime(ThreadPool *tp, ThreadPriority p, ThreadPoolJob *job)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
unsigned long diff;
|
unsigned long diff;
|
||||||
|
|
||||||
assert( tp != NULL );
|
assert(tp != NULL);
|
||||||
assert( job != NULL );
|
assert(job != NULL);
|
||||||
|
|
||||||
gettimeofday( &now, NULL );
|
gettimeofday(&now, NULL);
|
||||||
diff = DiffMillis( &now, &job->requestTime );
|
diff = DiffMillis(&now, &job->requestTime);
|
||||||
switch ( p ) {
|
switch (p) {
|
||||||
case LOW_PRIORITY:
|
case LOW_PRIORITY:
|
||||||
StatsAccountLQ( tp, diff );
|
StatsAccountLQ(tp, diff);
|
||||||
break;
|
break;
|
||||||
case MED_PRIORITY:
|
case MED_PRIORITY:
|
||||||
StatsAccountMQ( tp, diff );
|
StatsAccountMQ(tp, diff);
|
||||||
break;
|
break;
|
||||||
case HIGH_PRIORITY:
|
case HIGH_PRIORITY:
|
||||||
StatsAccountHQ( tp, diff );
|
StatsAccountHQ(tp, diff);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert( 0 );
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static time_t StatsTime( time_t *t )
|
static time_t StatsTime(time_t *t)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
gettimeofday( &tv, NULL );
|
gettimeofday(&tv, NULL);
|
||||||
if (t) {
|
if (t) {
|
||||||
*t = tv.tv_sec;
|
*t = tv.tv_sec;
|
||||||
}
|
}
|
||||||
@@ -168,12 +168,12 @@ static time_t StatsTime( time_t *t )
|
|||||||
return tv.tv_sec;
|
return tv.tv_sec;
|
||||||
}
|
}
|
||||||
#else /* STATS */
|
#else /* STATS */
|
||||||
static UPNP_INLINE void StatsInit( ThreadPoolStats *stats ) {}
|
static UPNP_INLINE void StatsInit(ThreadPoolStats *stats) {}
|
||||||
static UPNP_INLINE void StatsAccountLQ( ThreadPool *tp, unsigned long diffTime ) {}
|
static UPNP_INLINE void StatsAccountLQ(ThreadPool *tp, unsigned long diffTime) {}
|
||||||
static UPNP_INLINE void StatsAccountMQ( ThreadPool *tp, unsigned long diffTime ) {}
|
static UPNP_INLINE void StatsAccountMQ(ThreadPool *tp, unsigned long diffTime) {}
|
||||||
static UPNP_INLINE void StatsAccountHQ( ThreadPool *tp, unsigned long diffTime ) {}
|
static UPNP_INLINE void StatsAccountHQ(ThreadPool *tp, unsigned long diffTime) {}
|
||||||
static UPNP_INLINE void CalcWaitTime( ThreadPool *tp, ThreadPriority p, ThreadPoolJob *job ) {}
|
static UPNP_INLINE void CalcWaitTime(ThreadPool *tp, ThreadPriority p, ThreadPoolJob *job) {}
|
||||||
static UPNP_INLINE time_t StatsTime( time_t *t ) { return 0; }
|
static UPNP_INLINE time_t StatsTime(time_t *t) { return 0; }
|
||||||
#endif /* STATS */
|
#endif /* STATS */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -185,15 +185,15 @@ static UPNP_INLINE time_t StatsTime( time_t *t ) { return 0; }
|
|||||||
* void * - job A
|
* void * - job A
|
||||||
* void * - job B
|
* void * - job B
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static int CmpThreadPoolJob( void *jobA, void *jobB )
|
static int CmpThreadPoolJob(void *jobA, void *jobB)
|
||||||
{
|
{
|
||||||
ThreadPoolJob *a = ( ThreadPoolJob *) jobA;
|
ThreadPoolJob *a = (ThreadPoolJob *) jobA;
|
||||||
ThreadPoolJob *b = ( ThreadPoolJob *) jobB;
|
ThreadPoolJob *b = (ThreadPoolJob *) jobB;
|
||||||
|
|
||||||
assert( jobA != NULL );
|
assert(jobA != NULL);
|
||||||
assert( jobB != NULL );
|
assert(jobB != NULL);
|
||||||
|
|
||||||
return ( a->jobId == b->jobId );
|
return a->jobId == b->jobId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -204,11 +204,11 @@ static int CmpThreadPoolJob( void *jobA, void *jobB )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* ThreadPoolJob *tpj - must be allocated with CreateThreadPoolJob
|
* ThreadPoolJob *tpj - must be allocated with CreateThreadPoolJob
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static void FreeThreadPoolJob( ThreadPool *tp, ThreadPoolJob *tpj )
|
static void FreeThreadPoolJob(ThreadPool *tp, ThreadPoolJob *tpj)
|
||||||
{
|
{
|
||||||
assert( tp != NULL );
|
assert(tp != NULL);
|
||||||
|
|
||||||
FreeListFree( &tp->jobFreeList, tpj );
|
FreeListFree(&tp->jobFreeList, tpj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -224,22 +224,32 @@ static void FreeThreadPoolJob( ThreadPool *tp, ThreadPoolJob *tpj )
|
|||||||
* Returns result of GetLastError() on failure.
|
* Returns result of GetLastError() on failure.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static int SetPolicyType( PolicyType in )
|
static int SetPolicyType(PolicyType in)
|
||||||
{
|
{
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
/* TODO not currently working... */
|
/* TODO not currently working... */
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(__OSX__) || defined(__APPLE__)
|
#elif defined(__OSX__) || defined(__APPLE__)
|
||||||
setpriority( PRIO_PROCESS, 0, 0 );
|
setpriority(PRIO_PROCESS, 0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
return sched_setscheduler( 0, in );
|
return sched_setscheduler(0, in);
|
||||||
#elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
#elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||||
struct sched_param current;
|
struct sched_param current;
|
||||||
|
int rc;
|
||||||
|
|
||||||
sched_getparam( 0, ¤t );
|
memset(¤t, 0, sizeof(current)); /* purify? */
|
||||||
|
sched_getparam(0, ¤t);
|
||||||
current.sched_priority = DEFAULT_SCHED_PARAM;
|
current.sched_priority = DEFAULT_SCHED_PARAM;
|
||||||
return sched_setscheduler( 0, in, ¤t );
|
|
||||||
|
/* Solaris returns -1 if failure ..., but can return
|
||||||
|
* non-zero values for 0, ..., 5 [former scheduling values.] */
|
||||||
|
rc = sched_setscheduler(0, in, ¤t);
|
||||||
|
if (rc == -1) {
|
||||||
|
return rc;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -259,7 +269,7 @@ static int SetPolicyType( PolicyType in )
|
|||||||
* Returns result of GerLastError on failure.
|
* Returns result of GerLastError on failure.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static int SetPriority( ThreadPriority priority )
|
static int SetPriority(ThreadPriority priority)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||||
int currentPolicy;
|
int currentPolicy;
|
||||||
@@ -269,11 +279,11 @@ static int SetPriority( ThreadPriority priority )
|
|||||||
int midPriority = 0;
|
int midPriority = 0;
|
||||||
struct sched_param newPriority;
|
struct sched_param newPriority;
|
||||||
|
|
||||||
pthread_getschedparam( ithread_self(), ¤tPolicy, &newPriority );
|
pthread_getschedparam(ithread_self(), ¤tPolicy, &newPriority);
|
||||||
minPriority = sched_get_priority_min( currentPolicy );
|
minPriority = sched_get_priority_min(currentPolicy);
|
||||||
maxPriority = sched_get_priority_max( currentPolicy );
|
maxPriority = sched_get_priority_max(currentPolicy);
|
||||||
midPriority = ( maxPriority - minPriority ) / 2;
|
midPriority = (maxPriority - minPriority) / 2;
|
||||||
switch ( priority ) {
|
switch (priority) {
|
||||||
case LOW_PRIORITY:
|
case LOW_PRIORITY:
|
||||||
actPriority = minPriority;
|
actPriority = minPriority;
|
||||||
break;
|
break;
|
||||||
@@ -289,7 +299,7 @@ static int SetPriority( ThreadPriority priority )
|
|||||||
|
|
||||||
newPriority.sched_priority = actPriority;
|
newPriority.sched_priority = actPriority;
|
||||||
|
|
||||||
return pthread_setschedparam(ithread_self(), currentPolicy, &newPriority );
|
return pthread_setschedparam(ithread_self(), currentPolicy, &newPriority);
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -307,39 +317,38 @@ static int SetPriority( ThreadPriority priority )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* ThreadPool *tp
|
* ThreadPool *tp
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static void BumpPriority( ThreadPool *tp )
|
static void BumpPriority(ThreadPool *tp)
|
||||||
{
|
{
|
||||||
int done = 0;
|
int done = 0;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
unsigned long diffTime = 0;
|
unsigned long diffTime = 0;
|
||||||
ThreadPoolJob *tempJob = NULL;
|
ThreadPoolJob *tempJob = NULL;
|
||||||
|
|
||||||
assert( tp != NULL );
|
assert(tp != NULL);
|
||||||
|
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
|
while (!done) {
|
||||||
while( !done ) {
|
if (tp->medJobQ.size) {
|
||||||
if( tp->medJobQ.size ) {
|
tempJob = (ThreadPoolJob *)tp->medJobQ.head.next->item;
|
||||||
tempJob = ( ThreadPoolJob *) tp->medJobQ.head.next->item;
|
diffTime = DiffMillis(&now, &tempJob->requestTime);
|
||||||
diffTime = DiffMillis( &now, &tempJob->requestTime );
|
if (diffTime >= tp->attr.starvationTime) {
|
||||||
if( diffTime >= ( tp->attr.starvationTime ) ) {
|
/* If job has waited longer than the starvation time
|
||||||
// If job has waited longer than the starvation time
|
* bump priority (add to higher priority Q) */
|
||||||
// bump priority (add to higher priority Q)
|
StatsAccountMQ(tp, diffTime);
|
||||||
StatsAccountMQ( tp, diffTime );
|
ListDelNode(&tp->medJobQ, tp->medJobQ.head.next, 0);
|
||||||
ListDelNode( &tp->medJobQ, tp->medJobQ.head.next, 0 );
|
ListAddTail(&tp->highJobQ, tempJob);
|
||||||
ListAddTail( &tp->highJobQ, tempJob );
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( tp->lowJobQ.size ) {
|
if (tp->lowJobQ.size) {
|
||||||
tempJob = ( ThreadPoolJob *) tp->lowJobQ.head.next->item;
|
tempJob = (ThreadPoolJob *)tp->lowJobQ.head.next->item;
|
||||||
diffTime = DiffMillis( &now, &tempJob->requestTime );
|
diffTime = DiffMillis(&now, &tempJob->requestTime);
|
||||||
if( diffTime >= ( tp->attr.maxIdleTime ) ) {
|
if (diffTime >= tp->attr.maxIdleTime) {
|
||||||
// If job has waited longer than the starvation time
|
/* If job has waited longer than the starvation time
|
||||||
// bump priority (add to higher priority Q)
|
* bump priority (add to higher priority Q) */
|
||||||
StatsAccountLQ( tp, diffTime );
|
StatsAccountLQ(tp, diffTime);
|
||||||
ListDelNode( &tp->lowJobQ, tp->lowJobQ.head.next, 0 );
|
ListDelNode(&tp->lowJobQ, tp->lowJobQ.head.next, 0);
|
||||||
ListAddTail( &tp->medJobQ, tempJob );
|
ListAddTail(&tp->medJobQ, tempJob);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined(_sun)
|
#if defined(__sun)
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#elif defined(BSD) && BSD >= 199306
|
#elif defined(BSD) && BSD >= 199306
|
||||||
@@ -3594,6 +3594,11 @@ void printNodes( IXML_Node * tmpRoot, int depth )
|
|||||||
struct sockaddr_in LocalAddr;
|
struct sockaddr_in LocalAddr;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
|
/* purify */
|
||||||
|
memset(&ifConf, 0, sizeof(ifConf));
|
||||||
|
memset(&ifReq, 0, sizeof(ifReq));
|
||||||
|
memset(szBuffer, 0, sizeof(szBuffer));
|
||||||
|
|
||||||
// Create an unbound datagram socket to do the SIOCGIFADDR ioctl on.
|
// Create an unbound datagram socket to do the SIOCGIFADDR ioctl on.
|
||||||
if( ( LocalSock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) < 0 ) {
|
if( ( LocalSock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) < 0 ) {
|
||||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
|
|||||||
Reference in New Issue
Block a user