Merge of trunk into branch-1.6.x.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@284 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2007-12-27 02:14:02 +00:00
parent 7d4a610b93
commit f6dd5062fe
12 changed files with 1169 additions and 1367 deletions

View File

@ -1,3 +1,32 @@
*******************************************************************************
Version 1.6.3
*******************************************************************************
2007-12-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Using pthread flags for the whole project, not just at the places
individually indicated by several Makefile.am files spread all over
the directories. That was too much error prone.
2007-12-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Added a configure test to check if pthread_rwlock_t is available.
Define _GNU_SOURCE if needed. The fallback behaviou will only be
implemented if _GNU_SOURCE prooves to be insufficient on some
platforms. Thanks to Jonathan Casiot (no_dice) and Robert Gingher
(robsbox).
2007-12-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Removed unused iasnprintf.{c,h} files.
2007-12-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Removed STATSONLY() macro from ThreadPool.{c,h}.
* Removed time() usage from ThreadPool.c.
* Fixed STATS = 0 compilation.
2007-12-16 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Library was not compiling on FreeBSD 7. Code now no longer uses
ftime(), using gettimeofday() instead. Thanks to Josh Carroll.
******************************************************************************* *******************************************************************************
Version 1.6.2 Version 1.6.2
******************************************************************************* *******************************************************************************
@ -358,7 +387,7 @@ Version 1.4.2
2007-01-23 Marcelo Jimenez <mroberto(at)users.sourceforge.net> 2007-01-23 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Tracker [ 1634922 ] Support for large files (>= 2 GiB), part 2 * SF Tracker [ 1634922 ] Support for large files (>= 2 GiB), part 2
Submitted By: Jonathan - no_dice Submitted By: Jonathan Casiot - no_dice
Summary: This patch hopefully fixes the remaining types and related Summary: This patch hopefully fixes the remaining types and related
code to enable files >= 2 GiB to be streamed. Jonathan claims to have code to enable files >= 2 GiB to be streamed. Jonathan claims to have
tested this with a patched version of ushare-0.9.8 and a D-Link DSM-520. tested this with a patched version of ushare-0.9.8 and a D-Link DSM-520.

8
THANKS
View File

@ -22,18 +22,20 @@ exempt of errors.
- Glen Masgai - Glen Masgai
- Jiri Zouhar - Jiri Zouhar
- John Dennis - John Dennis
- Jonathan (no_dice) - Jonathan Casiot (no_dice)
- Josh Carroll
- Keith Brindley - Keith Brindley
- Leuk_He - Leuk_He
- Loigu - Loigu
- Luke Kim - Luke Kim
- Marcelo Roberto Jimenez (mroberto) - Marcelo Roberto Jimenez (mroberto)
- Markus Strobl - Markus Strobl
- Nektarios K. Papadopoulos - Nektarios K. Papadopoulos (npapadop)
- Oskar Liljeblad - Oskar Liljeblad
- Michael (Oxy) - Michael (oxygenic)
- Paul Vixie - Paul Vixie
- Rene Hexel - Rene Hexel
- Robert Gingher (robsbox)
- Siva Chandran - Siva Chandran
- Stéphane Corthésy - Stéphane Corthésy
- Steve Bresson - Steve Bresson

View File

@ -9,103 +9,115 @@
AC_PREREQ(2.60) AC_PREREQ(2.60)
AC_INIT([libupnp], [1.6.2], [mroberto@users.sourceforge.net]) AC_INIT([libupnp], [1.6.3], [mroberto@users.sourceforge.net])
############################################################################### dnl ############################################################################
# *Independently* of the above libupnp package version, the libtool version dnl # *Independently* of the above libupnp package version, the libtool version
# of the 3 libraries need to be updated whenever there is a change released: dnl # of the 3 libraries need to be updated whenever there is a change released:
# "current:revision:age" (this is NOT the same as the package version), where: dnl # "current:revision:age" (this is NOT the same as the package version),
# - library code modified: revision++ dnl # where:
# - interfaces changed/added/removed: current++ and revision=0 dnl # - library code modified: revision++
# - interfaces added: age++ dnl # - interfaces changed/added/removed: current++ and revision=0
# - interfaces removed: age=0 dnl # - interfaces added: age++
# *please update only once, before a formal release, not for each change* dnl # - interfaces removed: age=0
# dnl # *please update only once, before a formal release, not for each change*
############################################################################### dnl #
# Release 1.4.1: dnl ############################################################################
#AC_SUBST([LT_VERSION_IXML], [2:2:0]) dnl # Release 1.4.1:
#AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0]) dnl #AC_SUBST([LT_VERSION_IXML], [2:2:0])
#AC_SUBST([LT_VERSION_UPNP], [2:2:0]) dnl #AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
# dnl #AC_SUBST([LT_VERSION_UPNP], [2:2:0])
############################################################################### dnl #
# Release 1.4.6: dnl ############################################################################
# "current:revision:age" dnl # Release 1.4.6:
# dnl # "current:revision:age"
# - Code has changed in ixml dnl #
# revision: 2 -> 3 dnl # - Code has changed in ixml
# - Code has changed in threadutil dnl # revision: 2 -> 3
# revision: 2 -> 3 dnl # - Code has changed in threadutil
# - Interface added in threadutil dnl # revision: 2 -> 3
# current: 2 -> 3 dnl # - Interface added in threadutil
# revisiion: 3 -> 0 dnl # current: 2 -> 3
# age: 0 -> 1 dnl # revisiion: 3 -> 0
# - Code has changed in upnp dnl # age: 0 -> 1
# revision: 2 -> 3 dnl # - Code has changed in upnp
# dnl # revision: 2 -> 3
#AC_SUBST([LT_VERSION_IXML], [2:3:0]) dnl #
#AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1]) dnl #AC_SUBST([LT_VERSION_IXML], [2:3:0])
#AC_SUBST([LT_VERSION_UPNP], [2:3:0]) dnl #AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
# dnl #AC_SUBST([LT_VERSION_UPNP], [2:3:0])
############################################################################### dnl #
# Release 1.6.0: dnl ############################################################################
# "current:revision:age" dnl # Release 1.6.0:
# dnl # "current:revision:age"
# - Code has changed in ixml dnl #
# revision: 3 -> 4 dnl # - Code has changed in ixml
# - Code has changed in threadutil dnl # revision: 3 -> 4
# revision: 0 -> 1 dnl # - Code has changed in threadutil
# - Code has changed in upnp dnl # revision: 0 -> 1
# revision: 3 -> 4 dnl # - Code has changed in upnp
# - Interface changed in upnp dnl # revision: 3 -> 4
# current: 2 -> 3 dnl # - Interface changed in upnp
# revision: 4 -> 0 dnl # current: 2 -> 3
# - Interface removed in upnp dnl # revision: 4 -> 0
# age: 0 -> 0 dnl # - Interface removed in upnp
# dnl # age: 0 -> 0
#AC_SUBST([LT_VERSION_IXML], [2:4:0]) dnl #
#AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1]) dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
#AC_SUBST([LT_VERSION_UPNP], [3:0:0]) dnl #AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1])
# dnl #AC_SUBST([LT_VERSION_UPNP], [3:0:0])
############################################################################### dnl #
# Release 1.6.1: dnl ############################################################################
# "current:revision:age" dnl # Release 1.6.1:
# dnl # "current:revision:age"
# - Code has changed in threadutil dnl #
# revision: 1 -> 2 dnl # - Code has changed in threadutil
# - Interface added in threadutil dnl # revision: 1 -> 2
# current: 3 -> 4 dnl # - Interface added in threadutil
# revision: 2 -> 0 dnl # current: 3 -> 4
# - Interface added in threadutil dnl # revision: 2 -> 0
# age: 1 -> 2 dnl # - Interface added in threadutil
# - Code has changed in upnp dnl # age: 1 -> 2
# revision: 0 -> 1 dnl # - Code has changed in upnp
# dnl # revision: 0 -> 1
#AC_SUBST([LT_VERSION_IXML], [2:4:0]) dnl #
#AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2]) dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
#AC_SUBST([LT_VERSION_UPNP], [3:1:0]) dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
# dnl #AC_SUBST([LT_VERSION_UPNP], [3:1:0])
############################################################################### dnl #
# Release 1.6.2: dnl ############################################################################
# "current:revision:age" dnl # Release 1.6.2:
# dnl # "current:revision:age"
# - Code has changed in upnp dnl #
# revision: 1 -> 2 dnl # - Code has changed in upnp
# dnl # revision: 1 -> 2
#AC_SUBST([LT_VERSION_IXML], [2:4:0]) dnl #
#AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2]) dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
#AC_SUBST([LT_VERSION_UPNP], [3:2:0]) dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
# dnl #AC_SUBST([LT_VERSION_UPNP], [3:2:0])
############################################################################### dnl #
dnl ############################################################################
dnl # Release 1.6.3:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 0 -> 1
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:1:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:2:0])
dnl #
dnl ############################################################################
AC_SUBST([LT_VERSION_IXML], [2:4:0]) AC_SUBST([LT_VERSION_IXML], [2:4:0])
AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2]) AC_SUBST([LT_VERSION_THREADUTIL], [4:1:2])
AC_SUBST([LT_VERSION_UPNP], [3:2:0]) AC_SUBST([LT_VERSION_UPNP], [3:2:0])
############################################################################### dnl ############################################################################
# Repeating the algorithm so that it is closer to the modificatin place: dnl # Repeating the algorithm to place it closer to the modificatin place:
# - library code modified: revision++ dnl # - library code modified: revision++
# - interfaces changed/added/removed: current++ and revision=0 dnl # - interfaces changed/added/removed: current++ and revision=0
# - interfaces added: age++ dnl # - interfaces added: age++
# - interfaces removed: age=0 dnl # - interfaces removed: age=0
# *please update only once, before a formal release, not for each change* dnl # *please update only once, before a formal release, not for each change*
############################################################################### dnl ############################################################################
AC_CONFIG_AUX_DIR(config.aux) AC_CONFIG_AUX_DIR(config.aux)
@ -140,8 +152,7 @@ AC_REVISION([$Revision: 1.11 $])
upnpmaj=`echo "$PACKAGE_VERSION" | sed 's/\..*//' ` upnpmaj=`echo "$PACKAGE_VERSION" | sed 's/\..*//' `
upnpmin=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.// ; s/[^0-9].*$//' `] upnpmin=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.// ; s/[^0-9].*$//' `]
upnppatch=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.[^.]\.// ; s/[^0-9].*$//' `] upnppatch=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.[^.]\.// ; s/[^0-9].*$//' `]
AC_DEFINE_UNQUOTED([UPNP_VERSION_STRING], "$PACKAGE_VERSION", AC_DEFINE_UNQUOTED([UPNP_VERSION_STRING], "$PACKAGE_VERSION", [see upnpconfig.h])
[see upnpconfig.h])
AC_DEFINE_UNQUOTED([UPNP_VERSION_MAJOR], $upnpmaj, [see upnpconfig.h]) AC_DEFINE_UNQUOTED([UPNP_VERSION_MAJOR], $upnpmaj, [see upnpconfig.h])
AC_DEFINE_UNQUOTED([UPNP_VERSION_MINOR], $upnpmin, [see upnpconfig.h]) AC_DEFINE_UNQUOTED([UPNP_VERSION_MINOR], $upnpmin, [see upnpconfig.h])
AC_DEFINE_UNQUOTED([UPNP_VERSION_PATCH], $upnppatch, [see upnpconfig.h]) AC_DEFINE_UNQUOTED([UPNP_VERSION_PATCH], $upnppatch, [see upnpconfig.h])
@ -163,7 +174,6 @@ fi
# #
# Check for libupnp subsets # Check for libupnp subsets
# #
RT_BOOL_ARG_ENABLE([client], [yes], [control point code (client)]) RT_BOOL_ARG_ENABLE([client], [yes], [control point code (client)])
if test "x$enable_client" = xyes ; then if test "x$enable_client" = xyes ; then
AC_DEFINE(UPNP_HAVE_CLIENT, 1, [see upnpconfig.h]) AC_DEFINE(UPNP_HAVE_CLIENT, 1, [see upnpconfig.h])
@ -197,11 +207,13 @@ fi
RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code]) RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code])
#
# doc installation # doc installation
# autoconf >= 2.60 already defines ${docdir}, but we will not use its # autoconf >= 2.60 already defines ${docdir}, but we will not use its
# default value, which is ${datarootdir}/doc/${PACKAGE_TARNAME}. # default value, which is ${datarootdir}/doc/${PACKAGE_TARNAME}.
# That would give us ${datarootdir}/doc/libupnp, and we want the package # That would give us ${datarootdir}/doc/libupnp, and we want the package
# version on that. # version on that.
#
docdir="${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}" docdir="${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}"
AC_MSG_CHECKING([for documentation directory]) AC_MSG_CHECKING([for documentation directory])
AC_ARG_WITH( AC_ARG_WITH(
@ -216,7 +228,9 @@ AS_HELP_STRING(
[], [],
[with_documentation=no]) [with_documentation=no])
#
# If something has been entered after an equal sign, assume it is the directory # If something has been entered after an equal sign, assume it is the directory
#
if test x"$with_documentation" != xyes -a x"$with_documentation" != xno; then if test x"$with_documentation" != xyes -a x"$with_documentation" != xno; then
docdir="$with_documentation" docdir="$with_documentation"
fi fi
@ -302,7 +316,6 @@ AC_CHECK_HEADERS(
# Checks for typedefs, structures, and compiler characteristics # Checks for typedefs, structures, and compiler characteristics
# #
AC_C_CONST AC_C_CONST
AC_TYPE_SIZE_T
TYPE_SOCKLEN_T TYPE_SOCKLEN_T
@ -317,9 +330,40 @@ AC_CHECK_FUNCS(ftime,, [AC_CHECK_LIB(compat, ftime)])
# #
# Checks for POSIX Threads # Checks for POSIX Threads
# #
echo "--------------------------- pthread stuff -------------------------------------"
ACX_PTHREAD( ACX_PTHREAD(
[], [],
[AC_MSG_ERROR([POSIX threads are required to build this program])]) [AC_MSG_ERROR([POSIX threads are required to build this program])])
#
# Update environment variables for pthreads
#
CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
#
# Determine if pthread_rwlock_t is available
#
echo "----------------------- pthread_rwlock_t stuff --------------------------------"
AC_MSG_CHECKING([if pthread_rwlock_t is available])
AC_LANG([C])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#include <pthread.h>],
[pthread_rwlock_t *x;])],
[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
AC_MSG_RESULT([yes, supported without any options])],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#define _GNU_SOURCE
#include <pthread.h>],
[pthread_rwlock_t *x;])],
[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
AC_MSG_RESULT([yes, definition of _GNU_SOURCE required])],
[AC_DEFINE([UPNP_USE_RWLOCK], [0], [Do not use pthread_rwlock_t])
AC_MSG_RESULT([no, needs to fallback to pthread_mutex])
AC_MSG_ERROR([pthread_rwlock_t not available])])])
echo "-------------------------------------------------------------------------------"
AC_CONFIG_FILES([ AC_CONFIG_FILES([

View File

@ -38,11 +38,7 @@
#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) ) #define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) ) #define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
#ifndef WIN32 #define MEMBUF_DEF_SIZE_INC 20
#define UPNP_INLINE inline
#endif
#define MEMBUF_DEF_SIZE_INC 20
typedef struct // ixml_membuf typedef struct // ixml_membuf

View File

@ -501,17 +501,22 @@ Parser_init( )
} }
/*================================================================ /*================================================================
* Parser_isValidEndElement * Parser_isValidEndElement
* check if a new node->nodeName matches top of element stack. * check if a new node->nodeName matches top of element stack.
* Internal to parser only. * Internal to parser only.
* *=================================================================*/
*=================================================================*/
static int static int
Parser_isValidEndElement( IN Parser * xmlParser, Parser_isValidEndElement(
IN IXML_Node * newNode ) IN Parser * xmlParser,
IN IXML_Node * newNode )
{ {
return ( strcmp( xmlParser->pCurElement->element, newNode->nodeName ) assert( xmlParser );
== 0 ); assert( xmlParser->pCurElement );
assert( xmlParser->pCurElement->element );
assert( newNode );
assert( newNode->nodeName );
return strcmp( xmlParser->pCurElement->element, newNode->nodeName ) == 0;
} }
/*=============================================================== /*===============================================================
@ -921,6 +926,8 @@ Parser_parseDocument( OUT IXML_Document ** retDoc,
int rc = IXML_SUCCESS; int rc = IXML_SUCCESS;
IXML_CDATASection *cdataSecNode = NULL; IXML_CDATASection *cdataSecNode = NULL;
// It is important that the node gets initialized here, otherwise things
// can go wrong on the error handler.
ixmlNode_init( &newNode ); ixmlNode_init( &newNode );
rc = ixmlDocument_createDocumentEx( &gRootDoc ); rc = ixmlDocument_createDocumentEx( &gRootDoc );
@ -936,7 +943,9 @@ Parser_parseDocument( OUT IXML_Document ** retDoc,
} }
while( bETag == FALSE ) { while( bETag == FALSE ) {
// clear the newNode contents // clear the newNode contents. Redundant on the first iteration,
// but nonetheless, necessary due to the possible calls to
// ErrorHandler above. Currently, this is just a memset to zero.
ixmlNode_init( &newNode ); ixmlNode_init( &newNode );
if( Parser_getNextNode( xmlParser, &newNode, &bETag ) == if( Parser_getNextNode( xmlParser, &newNode, &bETag ) ==
@ -1030,7 +1039,7 @@ Parser_parseDocument( OUT IXML_Document ** retDoc,
Parser_free( xmlParser ); Parser_free( xmlParser );
return rc; return rc;
ErrorHandler: ErrorHandler:
Parser_freeNodeContent( &newNode ); Parser_freeNodeContent( &newNode );
ixmlDocument_free( gRootDoc ); ixmlDocument_free( gRootDoc );
Parser_free( xmlParser ); Parser_free( xmlParser );
@ -2497,3 +2506,4 @@ Parser_getNextNode( IN Parser * xmlParser,
return IXML_SYNTAX_ERR; return IXML_SYNTAX_ERR;
} }

View File

@ -2,11 +2,10 @@
# #
# "Makefile.am" for "libupnp/threadutil" # "Makefile.am" for "libupnp/threadutil"
# #
# (C) Copyright 2005 Rémi Turboult <r3mi@users.sourceforge.net> # (C) Copyright 2005 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
# #
AM_CPPFLAGS = -I$(srcdir)/inc -I$(srcdir)/src/inc AM_CPPFLAGS = -I$(srcdir)/inc -I$(srcdir)/src/inc
AM_CFLAGS = $(PTHREAD_CFLAGS)
if ENABLE_DEBUG if ENABLE_DEBUG
AM_CPPFLAGS += -DDEBUG -DSTATS AM_CPPFLAGS += -DDEBUG -DSTATS
@ -21,12 +20,11 @@ libthreadutil_la_LDFLAGS = -version-info $(LT_VERSION_THREADUTIL)
libthreadutil_la_SOURCES = \ libthreadutil_la_SOURCES = \
src/FreeList.c src/LinkedList.c \ src/FreeList.c src/LinkedList.c \
src/ThreadPool.c src/TimerThread.c \ src/ThreadPool.c src/TimerThread.c
src/iasnprintf.c
upnpincludedir = $(includedir)/upnp upnpincludedir = $(includedir)/upnp
upnpinclude_HEADERS = \ upnpinclude_HEADERS = \
inc/FreeList.h inc/LinkedList.h \ inc/FreeList.h inc/LinkedList.h \
inc/ThreadPool.h inc/TimerThread.h \ inc/ThreadPool.h inc/TimerThread.h \
inc/iasnprintf.h inc/ithread.h inc/ithread.h

View File

@ -32,6 +32,12 @@
#ifndef THREADPOOL_H #ifndef THREADPOOL_H
#define THREADPOOL_H #define THREADPOOL_H
#ifdef UPNP_USE_MSVCPP
#define UPNP_INLINE
#else
#define UPNP_INLINE inline
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -64,32 +70,23 @@ typedef enum priority {LOW_PRIORITY,
#define DEFAULT_FREE_ROUTINE NULL /* default free routine used TPJobInit */ #define DEFAULT_FREE_ROUTINE NULL /* default free routine used TPJobInit */
#define DEFAULT_MAX_JOBS_TOTAL 100 /* default max jobs used TPAttrInit */ #define DEFAULT_MAX_JOBS_TOTAL 100 /* default max jobs used TPAttrInit */
#define STATS 1 /* always include stats because code change is minimal */
/* Statistics */ /* Statistics */
#ifdef WIN32 /* TODO: check why STATSONLY fails during compilation */ /* always include stats because code change is minimal */
#undef STATS #define STATS 1
#endif
#ifdef STATS
#define STATSONLY(x) x
#else
#define STATSONLY(x)
#endif
#ifdef _DEBUG #ifdef _DEBUG
#define DEBUG 1 #define DEBUG 1
#endif #endif
#include "LinkedList.h" #include "LinkedList.h"
#include <sys/timeb.h> #include <sys/time.h> /* for gettimeofday() */
#include "FreeList.h" #include "FreeList.h"
#include "ithread.h" #include "ithread.h"
#include <errno.h> #include <errno.h>
#include <sys/timeb.h>
#define EXPORT #define EXPORT
typedef int PolicyType; typedef int PolicyType;
#define DEFAULT_POLICY SCHED_OTHER #define DEFAULT_POLICY SCHED_OTHER
#define DEFAULT_SCHED_PARAM 0 /* default priority */ #define DEFAULT_SCHED_PARAM 0 /* default priority */
@ -111,26 +108,28 @@ typedef void (*free_routine)(void *arg);
*****************************************************************************/ *****************************************************************************/
typedef struct THREADPOOLATTR typedef struct THREADPOOLATTR
{ {
int minThreads; /* minThreads, ThreadPool will always maintain at least /* minThreads, ThreadPool will always maintain at least this many threads */
this many threads */ int minThreads;
int maxThreads; /* maxThreads, ThreadPool will never have more than this /* maxThreads, ThreadPool will never have more than this number of threads */
number of threads */ int maxThreads;
int maxIdleTime; /* maxIdleTime (in milliseconds) /* maxIdleTime (in milliseconds) this is the maximum time a thread will
this is the maximum time a thread will remain idle * remain idle before dying */
before dying */ int maxIdleTime;
int jobsPerThread; /* jobs per thread to maintain */ /* jobs per thread to maintain */
int jobsPerThread;
int maxJobsTotal; /* maximum number of jobs that can be queued totally. */ /* maximum number of jobs that can be queued totally. */
int maxJobsTotal;
int starvationTime; /* the time a low priority or med priority /* the time a low priority or med priority job waits before getting bumped
job waits before getting bumped * up a priority (in milliseconds) */
up a priority (in milliseconds) */ int starvationTime;
PolicyType schedPolicy; /* scheduling policy to use */
/* scheduling policy to use */
PolicyType schedPolicy;
} ThreadPoolAttr; } ThreadPoolAttr;
/**************************************************************************** /****************************************************************************
@ -141,12 +140,12 @@ typedef struct THREADPOOLATTR
*****************************************************************************/ *****************************************************************************/
typedef struct THREADPOOLJOB typedef struct THREADPOOLJOB
{ {
start_routine func; start_routine func;
void *arg; void *arg;
free_routine free_func; free_routine free_func;
struct timeb requestTime; struct timeval requestTime;
int priority; int priority;
int jobId; int jobId;
} ThreadPoolJob; } ThreadPoolJob;
/**************************************************************************** /****************************************************************************
@ -156,32 +155,28 @@ typedef struct THREADPOOLJOB
* Structure to hold statistics * Structure to hold statistics
*****************************************************************************/ *****************************************************************************/
#ifdef STATS
typedef struct TPOOLSTATS typedef struct TPOOLSTATS
{ {
double totalTimeHQ; double totalTimeHQ;
int totalJobsHQ; int totalJobsHQ;
double avgWaitHQ; double avgWaitHQ;
double totalTimeMQ; double totalTimeMQ;
int totalJobsMQ; int totalJobsMQ;
double avgWaitMQ; double avgWaitMQ;
double totalTimeLQ; double totalTimeLQ;
int totalJobsLQ; int totalJobsLQ;
double avgWaitLQ; double avgWaitLQ;
double totalWorkTime; double totalWorkTime;
double totalIdleTime; double totalIdleTime;
int workerThreads; int workerThreads;
int idleThreads; int idleThreads;
int persistentThreads; int persistentThreads;
int totalThreads; int totalThreads;
int maxThreads; int maxThreads;
int currentJobsHQ; int currentJobsHQ;
int currentJobsLQ; int currentJobsLQ;
int currentJobsMQ; int currentJobsMQ;
}ThreadPoolStats; } ThreadPoolStats;
#endif
/**************************************************************************** /****************************************************************************
@ -206,27 +201,24 @@ typedef struct TPOOLSTATS
typedef struct THREADPOOL typedef struct THREADPOOL
{ {
ithread_mutex_t mutex; /* mutex to protect job qs */ ithread_mutex_t mutex; /* mutex to protect job qs */
ithread_cond_t condition; /* condition variable to signal Q */ ithread_cond_t condition; /* condition variable to signal Q */
ithread_cond_t start_and_shutdown; /* condition variable for start ithread_cond_t start_and_shutdown; /* condition variable for start
and stop */ and stop */
int lastJobId; /* ids for jobs */ int lastJobId; /* ids for jobs */
int shutdown; /* whether or not we are shutting down */ int shutdown; /* whether or not we are shutting down */
int totalThreads; /* total number of threads */ int totalThreads; /* total number of threads */
int persistentThreads; /* number of persistent threads */ int persistentThreads; /* number of persistent threads */
FreeList jobFreeList; /* free list of jobs */ FreeList jobFreeList; /* free list of jobs */
LinkedList lowJobQ; /* low priority job Q */ LinkedList lowJobQ; /* low priority job Q */
LinkedList medJobQ; /* med priority job Q */ LinkedList medJobQ; /* med priority job Q */
LinkedList highJobQ; /* high priority job Q */ LinkedList highJobQ; /* high priority job Q */
ThreadPoolJob *persistentJob; /* persistent job */ ThreadPoolJob *persistentJob; /* persistent job */
ThreadPoolAttr attr; /* thread pool attributes */ ThreadPoolAttr attr; /* thread pool attributes */
#ifdef STATS /* statistics */
/* statistics */ ThreadPoolStats stats;
ThreadPoolStats stats;
#endif
} ThreadPool; } ThreadPool;
@ -267,8 +259,7 @@ typedef struct THREADPOOL
* INVALID_POLICY if schedPolicy can't be set * INVALID_POLICY if schedPolicy can't be set
* EMAXTHREADS if minimum threads is greater than maximum threads * EMAXTHREADS if minimum threads is greater than maximum threads
*****************************************************************************/ *****************************************************************************/
int ThreadPoolInit(ThreadPool *tp, int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
ThreadPoolAttr *attr);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolAddPersistent * Function: ThreadPoolAddPersistent
@ -290,9 +281,7 @@ int ThreadPoolInit(ThreadPool *tp,
* EOUTOFMEM not enough memory to add job. * EOUTOFMEM not enough memory to add job.
* EMAXTHREADS not enough threads to add persistent job. * EMAXTHREADS not enough threads to add persistent job.
*****************************************************************************/ *****************************************************************************/
int ThreadPoolAddPersistent (ThreadPool*tp, int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
ThreadPoolJob *job,
int *jobId);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolGetAttr * Function: ThreadPoolGetAttr
@ -307,8 +296,7 @@ int ThreadPoolAddPersistent (ThreadPool*tp,
* 0 on success, nonzero on failure * 0 on success, nonzero on failure
* Always returns 0. * Always returns 0.
*****************************************************************************/ *****************************************************************************/
int ThreadPoolGetAttr(ThreadPool *tp, int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
ThreadPoolAttr *out);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolSetAttr * Function: ThreadPoolSetAttr
* *
@ -322,8 +310,7 @@ int ThreadPoolGetAttr(ThreadPool *tp,
* 0 on success, nonzero on failure * 0 on success, nonzero on failure
* Returns INVALID_POLICY if policy can not be set. * Returns INVALID_POLICY if policy can not be set.
*****************************************************************************/ *****************************************************************************/
int ThreadPoolSetAttr(ThreadPool *tp, int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
ThreadPoolAttr *attr);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolAdd * Function: ThreadPoolAdd
@ -342,9 +329,7 @@ int ThreadPoolSetAttr(ThreadPool *tp,
* 0 on success, nonzero on failure * 0 on success, nonzero on failure
* EOUTOFMEM if not enough memory to add job. * EOUTOFMEM if not enough memory to add job.
*****************************************************************************/ *****************************************************************************/
int ThreadPoolAdd (ThreadPool*tp, int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId);
ThreadPoolJob *job,
int *jobId);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolRemove * Function: ThreadPoolRemove
@ -361,8 +346,7 @@ int ThreadPoolAdd (ThreadPool*tp,
* 0 on success, nonzero on failure. * 0 on success, nonzero on failure.
* INVALID_JOB_ID if job not found. * INVALID_JOB_ID if job not found.
*****************************************************************************/ *****************************************************************************/
int ThreadPoolRemove(ThreadPool *tp, int ThreadPoolRemove(ThreadPool *tp, int jobId, ThreadPoolJob *out);
int jobId, ThreadPoolJob *out);
@ -425,7 +409,6 @@ int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
*****************************************************************************/ *****************************************************************************/
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func); int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
/**************************************************************************** /****************************************************************************
* Function: TPAttrInit * Function: TPAttrInit
* *

View File

@ -1,66 +0,0 @@
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include <stdarg.h>
#define EXPORT
#ifdef __cplusplus
extern "C" {
#endif
/**
* Allocates enough memory for the
* Formatted string, up to max
* specified.
* With max set to -1, allocates
* as much size as needed.
* Memory must be freed using free.
*/
EXPORT int iasnprintf(char **ret,
int incr,
int max,
const char * fmt, ...)
#ifndef SPARC_SOLARIS
#if (__GNUC__ >= 3)
__attribute__((format (__printf__, 4, 5)));
#else
;
#endif
EXPORT void iasnprintfFree(char *);
#else
;
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,153 +0,0 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#include <stdarg.h>
#include <assert.h>
#include <sys/param.h>
#if (defined(BSD) && BSD >= 199306) || defined(__OSX__)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <stdio.h>
#include "iasnprintf.h"
#ifndef NULL
#define NULL 0
#endif
#ifdef WIN32
#define vsnprintf _vsnprintf
#endif
/**
* Allocates enough memory for the
* Formatted string, up to max
* specified.
* With max set to -1, it allocates as
* much size as needed.
* Memory must be freed using free.
*/
int
iasnprintf( char **ret,
int incr,
int max,
const char *fmt,
... )
{
int size = incr;
int retc = 0;
va_list ap;
char *temp = NULL;
assert( ret );
assert( fmt );
( *ret ) = ( char * )malloc( incr );
if( ( *ret ) == NULL ) return -1;
while( 1 ) {
va_start( ap, fmt );
retc = vsnprintf( ( *ret ), size, fmt, ap );
va_end( ap );
if( retc < 0 ) {
//size not big enough
//and vsnprintf does NOT return the
//necessary number of bytes
if( ( max != -1 ) && ( size == max ) ) //max reached
{
break;
}
incr *= 2; //increase increment
//increase size and try again
if( ( max != -1 ) && ( ( size + incr ) > max ) ) {
incr = ( max - size );
}
temp = ( char * )realloc( ( *ret ), size + incr );
if( temp == NULL ) {
break;
}
size += incr;
( *ret ) = temp;
} else {
if( ( retc + 1 ) > size ) {
//size not big enough
//and vsnprintf
//returns the necessary
//number of bytes
if( ( max != -1 ) && ( retc + 1 > max ) ) {
retc = -1;
break;
}
temp = ( char * )realloc( ( *ret ), retc + 1 );
if( temp == NULL ) {
retc = -1;
break;
}
size = retc + 1;
( *ret ) = temp; //size increased try again
} else if( ( retc + 1 ) < size ) {
//size is bigger than needed
//try and reallocate smaller
temp = ( char * )realloc( ( *ret ), retc + 1 );
if( temp != NULL ) {
( *ret ) = temp;
}
break;
} else //size is just right, exit
{
break;
}
}
}
if( retc < 0 ) {
free( ( *ret ) );
( *ret ) = NULL;
}
return retc;
}
void
iasnprintfFree( char *fChar )
{
free( fChar );
fChar = NULL;
}

View File

@ -1,7 +1,7 @@
# #
# "Makefile.am" for "libupnp/upnp" # "Makefile.am" for "libupnp/upnp"
# #
# Copyright (C) 2005 Rémi Turboult <r3mi@users.sourceforge.net> # Copyright (C) 2005 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
# #
SUBDIRS = doc . sample SUBDIRS = doc . sample
@ -11,10 +11,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/threadutil/inc \ -I$(top_srcdir)/threadutil/inc \
-I$(top_srcdir)/ixml/inc -I$(top_srcdir)/ixml/inc
AM_CFLAGS = $(PTHREAD_CFLAGS)
AM_LDFLAGS = $(PTHREAD_LIBS)
LDADD = \ LDADD = \
libupnp.la \ libupnp.la \
$(top_builddir)/threadutil/libthreadutil.la \ $(top_builddir)/threadutil/libthreadutil.la \

View File

@ -9,10 +9,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/threadutil/inc \ -I$(top_srcdir)/threadutil/inc \
-I$(top_srcdir)/ixml/inc -I$(top_srcdir)/ixml/inc
AM_CFLAGS = $(PTHREAD_CFLAGS)
AM_LDFLAGS = $(PTHREAD_LIBS)
LDADD = \ LDADD = \
$(top_builddir)/upnp/libupnp.la \ $(top_builddir)/upnp/libupnp.la \
$(top_builddir)/threadutil/libthreadutil.la \ $(top_builddir)/threadutil/libthreadutil.la \