SF Tracker [ 1628562 ] Maximum total jobs patch

Submitted By: 
Fredrik Svensson - svefredrik

Incremented the libray versions and included some comments in the file
configure.ac so that we do not bump the library version excessively,
only the necessary numbers on the next release.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@115 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2007-01-06 19:16:12 +00:00
parent ae7ca6a2cf
commit c6d3d63223
5 changed files with 93 additions and 15 deletions

View File

@ -19,9 +19,27 @@ AC_INIT([libupnp], [1.4.1], [virtual_worlds@gmx.de])
# - interfaces added: age++
# - interfaces removed: age=0
# *please update only once, before a formal release, not for each change*
AC_SUBST([LT_VERSION_IXML], [2:2:0])
AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
AC_SUBST([LT_VERSION_UPNP], [2:2:0])
#
# For release 1.4.1, we had:
#AC_SUBST([LT_VERSION_IXML], [2:2:0])
#AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
#AC_SUBST([LT_VERSION_UPNP], [2:2:0])
#
# "current:revision:age"
#
# - Code has changed in ixml
# revision: 2 -> 3
# - Code has changed in threadutil
# revision: 2 -> 3
# - Interface added in threadutil
# current: 2 -> 3
# revisiion: 3 -> 0
# age: 0 -> 1
# - Code has changed in upnp (revision 2 -> 3)
# revision: 2 -> 3
AC_SUBST([LT_VERSION_IXML], [2:3:0])
AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
AC_SUBST([LT_VERSION_UPNP], [2:3:0])
AC_CONFIG_AUX_DIR(config.aux)

View File

@ -62,6 +62,7 @@ typedef enum priority {LOW_PRIORITY,
#define DEFAULT_STARVATION_TIME 500 //default starvation time used by TPAttrInit
#define DEFAULT_IDLE_TIME 10 * 1000 //default idle time used by TPAttrInit
#define DEFAULT_FREE_ROUTINE NULL //default free routine used TPJobInit
#define DEFAULT_MAX_JOBS_TOTAL 100 //default max jobs used TPAttrInit
#define STATS 1 //always include stats because code change is minimal
@ -119,23 +120,25 @@ typedef void (*free_routine)(void *arg);
*****************************************************************************/
typedef struct THREADPOOLATTR
{
int minThreads; //minThreads, ThreadPool will always maintain at least
//this many threads
int minThreads; // minThreads, ThreadPool will always maintain at least
// this many threads
int maxThreads; //maxThreads, ThreadPool will never have more than this
//number of threads
int maxThreads; // maxThreads, ThreadPool will never have more than this
// number of threads
int maxIdleTime; //maxIdleTime (in milliseconds)
// this is the maximum time a thread will remain idle
// before dying
int maxIdleTime; // maxIdleTime (in milliseconds)
// this is the maximum time a thread will remain idle
// before dying
int jobsPerThread; //jobs per thread to maintain
int jobsPerThread; // jobs per thread to maintain
int starvationTime; //the time a low priority or med priority
//job waits before getting bumped
//up a priority (in milliseconds)
int maxJobsTotal; // maximum number of jobs that can be queued totally.
PolicyType schedPolicy; //scheduling policy to use
int starvationTime; // the time a low priority or med priority
// job waits before getting bumped
// up a priority (in milliseconds)
PolicyType schedPolicy; // scheduling policy to use
} ThreadPoolAttr;
@ -521,6 +524,19 @@ int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime);
int TPAttrSetSchedPolicy(ThreadPoolAttr *attr, PolicyType schedPolicy);
/****************************************************************************
* Function: TPAttrSetMaxJobsTotal
*
* Description:
* Sets the maximum number jobs that can be qeued totally.
* Parameters:
* attr - must be valid thread pool attributes.
* maxJobsTotal - maximum number of jobs
* Returns:
* Always returns 0.
*****************************************************************************/
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
/****************************************************************************
* Function: ThreadPoolGetStats
*

View File

@ -906,6 +906,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
int rc = EOUTOFMEM;
int tempId = -1;
int totalJobs;
ThreadPoolJob *temp = NULL;
@ -922,6 +923,13 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|| ( job->priority == MED_PRIORITY )
|| ( job->priority == HIGH_PRIORITY ) );
totalJobs = tp->highJobQ.size + tp->lowJobQ.size + tp->medJobQ.size;
if (totalJobs >= tp->attr.maxJobsTotal) {
fprintf(stderr, "total jobs = %d, too many jobs", totalJobs);
ithread_mutex_unlock( &tp->mutex );
return rc;
}
if( jobId == NULL )
jobId = &tempId;
@ -1267,6 +1275,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
attr->minThreads = DEFAULT_MIN_THREADS;
attr->schedPolicy = DEFAULT_POLICY;
attr->starvationTime = DEFAULT_STARVATION_TIME;
attr->maxJobsTotal = DEFAULT_MAX_JOBS_TOTAL;
return 0;
}
@ -1518,6 +1527,29 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
stats->totalIdleTime );}
#endif
/****************************************************************************
* Function: TPAttrSetMaxJobsTotal
*
* Description:
* Sets the maximum number jobs that can be qeued totally.
* Parameters:
* attr - must be valid thread pool attributes.
* maxJobsTotal - maximum number of jobs
* Returns:
* Always returns 0.
*****************************************************************************/
int TPAttrSetMaxJobsTotal( ThreadPoolAttr * attr,
int maxJobsTotal ) {
assert( attr != NULL );
if( attr == NULL ) {
return EINVAL;
}
attr->maxJobsTotal = maxJobsTotal;
return 0;
}
/****************************************************************************
* Function: ThreadPoolGetStats
*

View File

@ -244,6 +244,7 @@ int UpnpInit( IN const char *HostIP,
TPAttrSetMinThreads( &attr, MIN_THREADS );
TPAttrSetJobsPerThread( &attr, JOBS_PER_THREAD );
TPAttrSetIdleTime( &attr, THREAD_IDLE_TIME );
TPAttrSetMaxJobsTotal( &attr, MAX_JOBS_TOTAL );
if( ThreadPoolInit( &gSendThreadPool, &attr ) != UPNP_E_SUCCESS ) {
UpnpSdkInit = 0;

View File

@ -95,6 +95,17 @@
#define MAX_THREADS 12
//@}
/** @name MAX_JOBS_TOTAL
* The {\tt MAX_JOBS_TOTAL} constant determines the maximum number of jobs
* that can be queued. If this limit is reached further jobs will be thrown
* to avoid memory exhaustion. The default value 100.
* (Added by Axis.)
*/
//@{
#define MAX_JOBS_TOTAL 100
//@}
/** @name DEFAULT_SOAP_CONTENT_LENGTH
* SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
* This prevents devices that have a misbehaving web server to send