workaround added for applications that don't catch SIGEPIPE
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.4.x@75 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
@@ -527,11 +527,15 @@ extern "C" {
|
||||
#define imillisleep(x) usleep(1000*x)
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef LIBUPNP_EXPORTS
|
||||
// set up declspec for dll export to make functions visible to library users
|
||||
#define EXPORT_SPEC __declspec(dllexport)
|
||||
#ifndef UPNP_STATIC_LIB
|
||||
#ifdef LIBUPNP_EXPORTS
|
||||
// set up declspec for dll export to make functions visible to library users
|
||||
#define EXPORT_SPEC __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SPEC __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC __declspec(dllimport)
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
|
||||
@@ -289,7 +289,8 @@ SetRelTimeout( struct timespec *time,
|
||||
* Parameters:
|
||||
* ThreadPoolStats *stats must be valid non null stats structure
|
||||
*****************************************************************************/
|
||||
STATSONLY( static void StatsInit( ThreadPoolStats * stats ) {
|
||||
#ifdef STATS
|
||||
static void StatsInit( ThreadPoolStats * stats ) {
|
||||
assert( stats != NULL ); stats->totalIdleTime = 0; stats->totalJobsHQ = 0; stats->totalJobsLQ = 0; stats->totalJobsMQ = 0; stats->totalTimeHQ = 0; stats->totalTimeMQ = 0; stats->totalTimeLQ = 0; stats->totalWorkTime = 0; stats->totalIdleTime = 0; stats->avgWaitHQ = 0; //average wait in HQ
|
||||
stats->avgWaitMQ = 0; //average wait in MQ
|
||||
stats->avgWaitLQ = 0;
|
||||
@@ -297,7 +298,7 @@ STATSONLY( static void StatsInit( ThreadPoolStats * stats ) {
|
||||
stats->idleThreads = 0;
|
||||
stats->persistentThreads = 0;
|
||||
stats->maxThreads = 0; stats->totalThreads = 0;}
|
||||
)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: CalcWaitTime
|
||||
@@ -313,7 +314,8 @@ STATSONLY( static void StatsInit( ThreadPoolStats * stats ) {
|
||||
* ThreadPriority p
|
||||
* ThreadPoolJob *job
|
||||
*****************************************************************************/
|
||||
STATSONLY( static void CalcWaitTime( ThreadPool * tp,
|
||||
#ifdef STATS
|
||||
static void CalcWaitTime( ThreadPool * tp,
|
||||
ThreadPriority p,
|
||||
ThreadPoolJob * job ) {
|
||||
struct timeb now;
|
||||
@@ -329,7 +331,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
assert( 0 );}
|
||||
}
|
||||
|
||||
)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: SetSeed
|
||||
@@ -380,6 +382,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
int retCode = 0;
|
||||
int persistent = -1;
|
||||
ThreadPool *tp = ( ThreadPool * ) arg;
|
||||
//leuk_he allow static linking
|
||||
#ifdef WIN32
|
||||
#ifdef PTW32_STATIC_LIB
|
||||
pthread_win32_thread_attach_np();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
assert( tp != NULL );
|
||||
|
||||
@@ -447,7 +455,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
tp->totalThreads--;
|
||||
ithread_cond_broadcast( &tp->start_and_shutdown );
|
||||
ithread_mutex_unlock( &tp->mutex );
|
||||
|
||||
//leuk_he
|
||||
#ifdef WIN32
|
||||
#ifdef PTW32_STATIC_LIB
|
||||
pthread_win32_thread_detach_np ();
|
||||
#endif
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -476,6 +489,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
ithread_cond_broadcast( &tp->start_and_shutdown );
|
||||
|
||||
ithread_mutex_unlock( &tp->mutex );
|
||||
//leuk_he
|
||||
#ifdef WIN32
|
||||
#ifdef PTW32_STATIC_LIB
|
||||
pthread_win32_thread_detach_np ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
} else {
|
||||
@@ -703,6 +722,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
if( tp == NULL ) {
|
||||
return EINVAL;
|
||||
}
|
||||
//leuk_he
|
||||
#ifdef WIN32
|
||||
#ifdef PTW32_STATIC_LIB
|
||||
pthread_win32_process_attach_np();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
retCode += ithread_mutex_init( &tp->mutex, NULL );
|
||||
assert( retCode == 0 );
|
||||
@@ -1461,7 +1486,8 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATSONLY( void ThreadPoolPrintStats( ThreadPoolStats * stats ) {
|
||||
#ifdef STATS
|
||||
void ThreadPoolPrintStats( ThreadPoolStats * stats ) {
|
||||
assert( stats != NULL ); if( stats == NULL ) {
|
||||
return;}
|
||||
|
||||
@@ -1471,13 +1497,13 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
printf( "ThreadPoolStats at Time: %ld\n", time( NULL ) );
|
||||
#endif
|
||||
printf
|
||||
( "Average Wait in High Priority Q in milliseconds: %lf\n",
|
||||
( "Average Wait in High Priority Q in milliseconds: %f\n",
|
||||
stats->avgWaitHQ );
|
||||
printf
|
||||
( "Average Wait in Med Priority Q in milliseconds: %lf\n",
|
||||
( "Average Wait in Med Priority Q in milliseconds: %f\n",
|
||||
stats->avgWaitMQ );
|
||||
printf
|
||||
( "Averate Wait in Low Priority Q in milliseconds: %lf\n",
|
||||
( "Averate Wait in Low Priority Q in milliseconds: %f\n",
|
||||
stats->avgWaitLQ );
|
||||
printf( "Max Threads Active: %d\n", stats->maxThreads );
|
||||
printf( "Current Worker Threads: %d\n",
|
||||
@@ -1486,11 +1512,11 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
stats->persistentThreads );
|
||||
printf( "Current Idle Threads: %d\n", stats->idleThreads );
|
||||
printf( "Total Threads : %d\n", stats->totalThreads );
|
||||
printf( "Total Time spent Working in seconds: %lf\n",
|
||||
printf( "Total Time spent Working in seconds: %f\n",
|
||||
stats->totalWorkTime );
|
||||
printf( "Total Time spent Idle in seconds : %lf\n",
|
||||
printf( "Total Time spent Idle in seconds : %f\n",
|
||||
stats->totalIdleTime );}
|
||||
)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolGetStats
|
||||
@@ -1505,7 +1531,8 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
* Returns:
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
STATSONLY( int
|
||||
#ifdef STATS
|
||||
int
|
||||
ThreadPoolGetStats( ThreadPool * tp,
|
||||
ThreadPoolStats * stats ) {
|
||||
|
||||
@@ -1542,4 +1569,4 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
|
||||
return 0;}
|
||||
|
||||
)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user