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:
parent
7d4a610b93
commit
f6dd5062fe
31
ChangeLog
31
ChangeLog
@ -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
|
||||
*******************************************************************************
|
||||
@ -358,7 +387,7 @@ Version 1.4.2
|
||||
2007-01-23 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
* 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
|
||||
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.
|
||||
|
8
THANKS
8
THANKS
@ -22,18 +22,20 @@ exempt of errors.
|
||||
- Glen Masgai
|
||||
- Jiri Zouhar
|
||||
- John Dennis
|
||||
- Jonathan (no_dice)
|
||||
- Jonathan Casiot (no_dice)
|
||||
- Josh Carroll
|
||||
- Keith Brindley
|
||||
- Leuk_He
|
||||
- Loigu
|
||||
- Luke Kim
|
||||
- Marcelo Roberto Jimenez (mroberto)
|
||||
- Markus Strobl
|
||||
- Nektarios K. Papadopoulos
|
||||
- Nektarios K. Papadopoulos (npapadop)
|
||||
- Oskar Liljeblad
|
||||
- Michael (Oxy)
|
||||
- Michael (oxygenic)
|
||||
- Paul Vixie
|
||||
- Rene Hexel
|
||||
- Robert Gingher (robsbox)
|
||||
- Siva Chandran
|
||||
- Stéphane Corthésy
|
||||
- Steve Bresson
|
||||
|
242
configure.ac
242
configure.ac
@ -9,103 +9,115 @@
|
||||
|
||||
AC_PREREQ(2.60)
|
||||
|
||||
AC_INIT([libupnp], [1.6.2], [mroberto@users.sourceforge.net])
|
||||
###############################################################################
|
||||
# *Independently* of the above libupnp package version, the libtool version
|
||||
# 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:
|
||||
# - library code modified: revision++
|
||||
# - interfaces changed/added/removed: current++ and revision=0
|
||||
# - interfaces added: age++
|
||||
# - interfaces removed: age=0
|
||||
# *please update only once, before a formal release, not for each change*
|
||||
#
|
||||
###############################################################################
|
||||
# Release 1.4.1:
|
||||
#AC_SUBST([LT_VERSION_IXML], [2:2:0])
|
||||
#AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
|
||||
#AC_SUBST([LT_VERSION_UPNP], [2:2:0])
|
||||
#
|
||||
###############################################################################
|
||||
# Release 1.4.6:
|
||||
# "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
|
||||
#
|
||||
#AC_SUBST([LT_VERSION_IXML], [2:3:0])
|
||||
#AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
|
||||
#AC_SUBST([LT_VERSION_UPNP], [2:3:0])
|
||||
#
|
||||
###############################################################################
|
||||
# Release 1.6.0:
|
||||
# "current:revision:age"
|
||||
#
|
||||
# - Code has changed in ixml
|
||||
# revision: 3 -> 4
|
||||
# - Code has changed in threadutil
|
||||
# revision: 0 -> 1
|
||||
# - Code has changed in upnp
|
||||
# revision: 3 -> 4
|
||||
# - Interface changed in upnp
|
||||
# current: 2 -> 3
|
||||
# revision: 4 -> 0
|
||||
# - Interface removed in upnp
|
||||
# age: 0 -> 0
|
||||
#
|
||||
#AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||
#AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1])
|
||||
#AC_SUBST([LT_VERSION_UPNP], [3:0:0])
|
||||
#
|
||||
###############################################################################
|
||||
# Release 1.6.1:
|
||||
# "current:revision:age"
|
||||
#
|
||||
# - Code has changed in threadutil
|
||||
# revision: 1 -> 2
|
||||
# - Interface added in threadutil
|
||||
# current: 3 -> 4
|
||||
# revision: 2 -> 0
|
||||
# - Interface added in threadutil
|
||||
# age: 1 -> 2
|
||||
# - Code has changed in upnp
|
||||
# revision: 0 -> 1
|
||||
#
|
||||
#AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||
#AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
||||
#AC_SUBST([LT_VERSION_UPNP], [3:1:0])
|
||||
#
|
||||
###############################################################################
|
||||
# Release 1.6.2:
|
||||
# "current:revision:age"
|
||||
#
|
||||
# - Code has changed in upnp
|
||||
# revision: 1 -> 2
|
||||
#
|
||||
#AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||
#AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
||||
#AC_SUBST([LT_VERSION_UPNP], [3:2:0])
|
||||
#
|
||||
###############################################################################
|
||||
AC_INIT([libupnp], [1.6.3], [mroberto@users.sourceforge.net])
|
||||
dnl ############################################################################
|
||||
dnl # *Independently* of the above libupnp package version, the libtool version
|
||||
dnl # of the 3 libraries need to be updated whenever there is a change released:
|
||||
dnl # "current:revision:age" (this is NOT the same as the package version),
|
||||
dnl # where:
|
||||
dnl # - library code modified: revision++
|
||||
dnl # - interfaces changed/added/removed: current++ and revision=0
|
||||
dnl # - interfaces added: age++
|
||||
dnl # - interfaces removed: age=0
|
||||
dnl # *please update only once, before a formal release, not for each change*
|
||||
dnl #
|
||||
dnl ############################################################################
|
||||
dnl # Release 1.4.1:
|
||||
dnl #AC_SUBST([LT_VERSION_IXML], [2:2:0])
|
||||
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
|
||||
dnl #AC_SUBST([LT_VERSION_UPNP], [2:2:0])
|
||||
dnl #
|
||||
dnl ############################################################################
|
||||
dnl # Release 1.4.6:
|
||||
dnl # "current:revision:age"
|
||||
dnl #
|
||||
dnl # - Code has changed in ixml
|
||||
dnl # revision: 2 -> 3
|
||||
dnl # - Code has changed in threadutil
|
||||
dnl # revision: 2 -> 3
|
||||
dnl # - Interface added in threadutil
|
||||
dnl # current: 2 -> 3
|
||||
dnl # revisiion: 3 -> 0
|
||||
dnl # age: 0 -> 1
|
||||
dnl # - Code has changed in upnp
|
||||
dnl # revision: 2 -> 3
|
||||
dnl #
|
||||
dnl #AC_SUBST([LT_VERSION_IXML], [2:3:0])
|
||||
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
|
||||
dnl #AC_SUBST([LT_VERSION_UPNP], [2:3:0])
|
||||
dnl #
|
||||
dnl ############################################################################
|
||||
dnl # Release 1.6.0:
|
||||
dnl # "current:revision:age"
|
||||
dnl #
|
||||
dnl # - Code has changed in ixml
|
||||
dnl # revision: 3 -> 4
|
||||
dnl # - Code has changed in threadutil
|
||||
dnl # revision: 0 -> 1
|
||||
dnl # - Code has changed in upnp
|
||||
dnl # revision: 3 -> 4
|
||||
dnl # - Interface changed in upnp
|
||||
dnl # current: 2 -> 3
|
||||
dnl # revision: 4 -> 0
|
||||
dnl # - Interface removed in upnp
|
||||
dnl # age: 0 -> 0
|
||||
dnl #
|
||||
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1])
|
||||
dnl #AC_SUBST([LT_VERSION_UPNP], [3:0:0])
|
||||
dnl #
|
||||
dnl ############################################################################
|
||||
dnl # Release 1.6.1:
|
||||
dnl # "current:revision:age"
|
||||
dnl #
|
||||
dnl # - Code has changed in threadutil
|
||||
dnl # revision: 1 -> 2
|
||||
dnl # - Interface added in threadutil
|
||||
dnl # current: 3 -> 4
|
||||
dnl # revision: 2 -> 0
|
||||
dnl # - Interface added in threadutil
|
||||
dnl # age: 1 -> 2
|
||||
dnl # - Code has changed in upnp
|
||||
dnl # revision: 0 -> 1
|
||||
dnl #
|
||||
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
||||
dnl #AC_SUBST([LT_VERSION_UPNP], [3:1:0])
|
||||
dnl #
|
||||
dnl ############################################################################
|
||||
dnl # Release 1.6.2:
|
||||
dnl # "current:revision:age"
|
||||
dnl #
|
||||
dnl # - Code has changed in upnp
|
||||
dnl # revision: 1 -> 2
|
||||
dnl #
|
||||
dnl #AC_SUBST([LT_VERSION_IXML], [2:4: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_THREADUTIL], [4:0:2])
|
||||
AC_SUBST([LT_VERSION_THREADUTIL], [4:1:2])
|
||||
AC_SUBST([LT_VERSION_UPNP], [3:2:0])
|
||||
###############################################################################
|
||||
# Repeating the algorithm so that it is closer to the modificatin place:
|
||||
# - library code modified: revision++
|
||||
# - interfaces changed/added/removed: current++ and revision=0
|
||||
# - interfaces added: age++
|
||||
# - interfaces removed: age=0
|
||||
# *please update only once, before a formal release, not for each change*
|
||||
###############################################################################
|
||||
dnl ############################################################################
|
||||
dnl # Repeating the algorithm to place it closer to the modificatin place:
|
||||
dnl # - library code modified: revision++
|
||||
dnl # - interfaces changed/added/removed: current++ and revision=0
|
||||
dnl # - interfaces added: age++
|
||||
dnl # - interfaces removed: age=0
|
||||
dnl # *please update only once, before a formal release, not for each change*
|
||||
dnl ############################################################################
|
||||
|
||||
|
||||
AC_CONFIG_AUX_DIR(config.aux)
|
||||
@ -140,8 +152,7 @@ AC_REVISION([$Revision: 1.11 $])
|
||||
upnpmaj=`echo "$PACKAGE_VERSION" | sed 's/\..*//' `
|
||||
upnpmin=[`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",
|
||||
[see upnpconfig.h])
|
||||
AC_DEFINE_UNQUOTED([UPNP_VERSION_STRING], "$PACKAGE_VERSION", [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_PATCH], $upnppatch, [see upnpconfig.h])
|
||||
@ -163,7 +174,6 @@ fi
|
||||
#
|
||||
# Check for libupnp subsets
|
||||
#
|
||||
|
||||
RT_BOOL_ARG_ENABLE([client], [yes], [control point code (client)])
|
||||
if test "x$enable_client" = xyes ; then
|
||||
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])
|
||||
|
||||
|
||||
#
|
||||
# doc installation
|
||||
# autoconf >= 2.60 already defines ${docdir}, but we will not use its
|
||||
# default value, which is ${datarootdir}/doc/${PACKAGE_TARNAME}.
|
||||
# That would give us ${datarootdir}/doc/libupnp, and we want the package
|
||||
# version on that.
|
||||
#
|
||||
docdir="${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}"
|
||||
AC_MSG_CHECKING([for documentation directory])
|
||||
AC_ARG_WITH(
|
||||
@ -216,7 +228,9 @@ AS_HELP_STRING(
|
||||
[],
|
||||
[with_documentation=no])
|
||||
|
||||
#
|
||||
# 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
|
||||
docdir="$with_documentation"
|
||||
fi
|
||||
@ -302,7 +316,6 @@ AC_CHECK_HEADERS(
|
||||
# Checks for typedefs, structures, and compiler characteristics
|
||||
#
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
TYPE_SOCKLEN_T
|
||||
|
||||
|
||||
@ -317,9 +330,40 @@ AC_CHECK_FUNCS(ftime,, [AC_CHECK_LIB(compat, ftime)])
|
||||
#
|
||||
# Checks for POSIX Threads
|
||||
#
|
||||
echo "--------------------------- pthread stuff -------------------------------------"
|
||||
ACX_PTHREAD(
|
||||
[],
|
||||
[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([
|
||||
|
@ -38,11 +38,7 @@
|
||||
#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
|
||||
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
|
||||
|
||||
#ifndef WIN32
|
||||
#define UPNP_INLINE inline
|
||||
#endif
|
||||
|
||||
#define MEMBUF_DEF_SIZE_INC 20
|
||||
#define MEMBUF_DEF_SIZE_INC 20
|
||||
|
||||
|
||||
typedef struct // ixml_membuf
|
||||
|
@ -501,17 +501,22 @@ Parser_init( )
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* Parser_isValidEndElement
|
||||
* check if a new node->nodeName matches top of element stack.
|
||||
* Internal to parser only.
|
||||
*
|
||||
*=================================================================*/
|
||||
* Parser_isValidEndElement
|
||||
* check if a new node->nodeName matches top of element stack.
|
||||
* Internal to parser only.
|
||||
*=================================================================*/
|
||||
static int
|
||||
Parser_isValidEndElement( IN Parser * xmlParser,
|
||||
IN IXML_Node * newNode )
|
||||
Parser_isValidEndElement(
|
||||
IN Parser * xmlParser,
|
||||
IN IXML_Node * newNode )
|
||||
{
|
||||
return ( strcmp( xmlParser->pCurElement->element, newNode->nodeName )
|
||||
== 0 );
|
||||
assert( xmlParser );
|
||||
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;
|
||||
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 );
|
||||
|
||||
rc = ixmlDocument_createDocumentEx( &gRootDoc );
|
||||
@ -936,7 +943,9 @@ Parser_parseDocument( OUT IXML_Document ** retDoc,
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
if( Parser_getNextNode( xmlParser, &newNode, &bETag ) ==
|
||||
@ -1030,7 +1039,7 @@ Parser_parseDocument( OUT IXML_Document ** retDoc,
|
||||
Parser_free( xmlParser );
|
||||
return rc;
|
||||
|
||||
ErrorHandler:
|
||||
ErrorHandler:
|
||||
Parser_freeNodeContent( &newNode );
|
||||
ixmlDocument_free( gRootDoc );
|
||||
Parser_free( xmlParser );
|
||||
@ -2497,3 +2506,4 @@ Parser_getNextNode( IN Parser * xmlParser,
|
||||
return IXML_SYNTAX_ERR;
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,10 @@
|
||||
#
|
||||
# "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_CFLAGS = $(PTHREAD_CFLAGS)
|
||||
|
||||
if ENABLE_DEBUG
|
||||
AM_CPPFLAGS += -DDEBUG -DSTATS
|
||||
@ -21,12 +20,11 @@ libthreadutil_la_LDFLAGS = -version-info $(LT_VERSION_THREADUTIL)
|
||||
|
||||
libthreadutil_la_SOURCES = \
|
||||
src/FreeList.c src/LinkedList.c \
|
||||
src/ThreadPool.c src/TimerThread.c \
|
||||
src/iasnprintf.c
|
||||
src/ThreadPool.c src/TimerThread.c
|
||||
|
||||
upnpincludedir = $(includedir)/upnp
|
||||
upnpinclude_HEADERS = \
|
||||
inc/FreeList.h inc/LinkedList.h \
|
||||
inc/ThreadPool.h inc/TimerThread.h \
|
||||
inc/iasnprintf.h inc/ithread.h
|
||||
inc/ithread.h
|
||||
|
||||
|
@ -32,6 +32,12 @@
|
||||
#ifndef THREADPOOL_H
|
||||
#define THREADPOOL_H
|
||||
|
||||
#ifdef UPNP_USE_MSVCPP
|
||||
#define UPNP_INLINE
|
||||
#else
|
||||
#define UPNP_INLINE inline
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -64,32 +70,23 @@ typedef enum priority {LOW_PRIORITY,
|
||||
#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 */
|
||||
|
||||
|
||||
/* Statistics */
|
||||
#ifdef WIN32 /* TODO: check why STATSONLY fails during compilation */
|
||||
#undef STATS
|
||||
#endif
|
||||
|
||||
#ifdef STATS
|
||||
#define STATSONLY(x) x
|
||||
#else
|
||||
#define STATSONLY(x)
|
||||
#endif
|
||||
/* always include stats because code change is minimal */
|
||||
#define STATS 1
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
|
||||
#include "LinkedList.h"
|
||||
#include <sys/timeb.h>
|
||||
#include <sys/time.h> /* for gettimeofday() */
|
||||
#include "FreeList.h"
|
||||
|
||||
#include "ithread.h"
|
||||
#include <errno.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
#define EXPORT
|
||||
|
||||
typedef int PolicyType;
|
||||
#define DEFAULT_POLICY SCHED_OTHER
|
||||
#define DEFAULT_SCHED_PARAM 0 /* default priority */
|
||||
@ -111,26 +108,28 @@ typedef void (*free_routine)(void *arg);
|
||||
*****************************************************************************/
|
||||
typedef struct THREADPOOLATTR
|
||||
{
|
||||
int minThreads; /* minThreads, ThreadPool will always maintain at least
|
||||
this many threads */
|
||||
/* minThreads, ThreadPool will always maintain at least this many threads */
|
||||
int minThreads;
|
||||
|
||||
int maxThreads; /* maxThreads, ThreadPool will never have more than this
|
||||
number of threads */
|
||||
/* maxThreads, ThreadPool will never have more than this number of threads */
|
||||
int maxThreads;
|
||||
|
||||
int maxIdleTime; /* maxIdleTime (in milliseconds)
|
||||
this is the maximum time a thread will remain idle
|
||||
before dying */
|
||||
/* maxIdleTime (in milliseconds) this is the maximum time a thread will
|
||||
* remain idle 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
|
||||
job waits before getting bumped
|
||||
up a priority (in milliseconds) */
|
||||
|
||||
PolicyType schedPolicy; /* scheduling policy to use */
|
||||
/* the time a low priority or med priority job waits before getting bumped
|
||||
* up a priority (in milliseconds) */
|
||||
int starvationTime;
|
||||
|
||||
/* scheduling policy to use */
|
||||
PolicyType schedPolicy;
|
||||
} ThreadPoolAttr;
|
||||
|
||||
/****************************************************************************
|
||||
@ -141,12 +140,12 @@ typedef struct THREADPOOLATTR
|
||||
*****************************************************************************/
|
||||
typedef struct THREADPOOLJOB
|
||||
{
|
||||
start_routine func;
|
||||
void *arg;
|
||||
free_routine free_func;
|
||||
struct timeb requestTime;
|
||||
int priority;
|
||||
int jobId;
|
||||
start_routine func;
|
||||
void *arg;
|
||||
free_routine free_func;
|
||||
struct timeval requestTime;
|
||||
int priority;
|
||||
int jobId;
|
||||
} ThreadPoolJob;
|
||||
|
||||
/****************************************************************************
|
||||
@ -156,32 +155,28 @@ typedef struct THREADPOOLJOB
|
||||
* Structure to hold statistics
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef STATS
|
||||
|
||||
typedef struct TPOOLSTATS
|
||||
{
|
||||
double totalTimeHQ;
|
||||
int totalJobsHQ;
|
||||
double avgWaitHQ;
|
||||
double totalTimeMQ;
|
||||
int totalJobsMQ;
|
||||
double avgWaitMQ;
|
||||
double totalTimeLQ;
|
||||
int totalJobsLQ;
|
||||
double avgWaitLQ;
|
||||
double totalWorkTime;
|
||||
double totalIdleTime;
|
||||
int workerThreads;
|
||||
int idleThreads;
|
||||
int persistentThreads;
|
||||
int totalThreads;
|
||||
int maxThreads;
|
||||
int currentJobsHQ;
|
||||
int currentJobsLQ;
|
||||
int currentJobsMQ;
|
||||
}ThreadPoolStats;
|
||||
|
||||
#endif
|
||||
double totalTimeHQ;
|
||||
int totalJobsHQ;
|
||||
double avgWaitHQ;
|
||||
double totalTimeMQ;
|
||||
int totalJobsMQ;
|
||||
double avgWaitMQ;
|
||||
double totalTimeLQ;
|
||||
int totalJobsLQ;
|
||||
double avgWaitLQ;
|
||||
double totalWorkTime;
|
||||
double totalIdleTime;
|
||||
int workerThreads;
|
||||
int idleThreads;
|
||||
int persistentThreads;
|
||||
int totalThreads;
|
||||
int maxThreads;
|
||||
int currentJobsHQ;
|
||||
int currentJobsLQ;
|
||||
int currentJobsMQ;
|
||||
} ThreadPoolStats;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
@ -206,27 +201,24 @@ typedef struct TPOOLSTATS
|
||||
|
||||
typedef struct THREADPOOL
|
||||
{
|
||||
ithread_mutex_t mutex; /* mutex to protect job qs */
|
||||
ithread_cond_t condition; /* condition variable to signal Q */
|
||||
ithread_cond_t start_and_shutdown; /* condition variable for start
|
||||
and stop */
|
||||
int lastJobId; /* ids for jobs */
|
||||
int shutdown; /* whether or not we are shutting down */
|
||||
int totalThreads; /* total number of threads */
|
||||
int persistentThreads; /* number of persistent threads */
|
||||
FreeList jobFreeList; /* free list of jobs */
|
||||
LinkedList lowJobQ; /* low priority job Q */
|
||||
LinkedList medJobQ; /* med priority job Q */
|
||||
LinkedList highJobQ; /* high priority job Q */
|
||||
ThreadPoolJob *persistentJob; /* persistent job */
|
||||
|
||||
ThreadPoolAttr attr; /* thread pool attributes */
|
||||
|
||||
#ifdef STATS
|
||||
/* statistics */
|
||||
ThreadPoolStats stats;
|
||||
#endif
|
||||
|
||||
ithread_mutex_t mutex; /* mutex to protect job qs */
|
||||
ithread_cond_t condition; /* condition variable to signal Q */
|
||||
ithread_cond_t start_and_shutdown; /* condition variable for start
|
||||
and stop */
|
||||
int lastJobId; /* ids for jobs */
|
||||
int shutdown; /* whether or not we are shutting down */
|
||||
int totalThreads; /* total number of threads */
|
||||
int persistentThreads; /* number of persistent threads */
|
||||
FreeList jobFreeList; /* free list of jobs */
|
||||
LinkedList lowJobQ; /* low priority job Q */
|
||||
LinkedList medJobQ; /* med priority job Q */
|
||||
LinkedList highJobQ; /* high priority job Q */
|
||||
ThreadPoolJob *persistentJob; /* persistent job */
|
||||
|
||||
ThreadPoolAttr attr; /* thread pool attributes */
|
||||
|
||||
/* statistics */
|
||||
ThreadPoolStats stats;
|
||||
} ThreadPool;
|
||||
|
||||
|
||||
@ -267,8 +259,7 @@ typedef struct THREADPOOL
|
||||
* INVALID_POLICY if schedPolicy can't be set
|
||||
* EMAXTHREADS if minimum threads is greater than maximum threads
|
||||
*****************************************************************************/
|
||||
int ThreadPoolInit(ThreadPool *tp,
|
||||
ThreadPoolAttr *attr);
|
||||
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolAddPersistent
|
||||
@ -290,9 +281,7 @@ int ThreadPoolInit(ThreadPool *tp,
|
||||
* EOUTOFMEM not enough memory to add job.
|
||||
* EMAXTHREADS not enough threads to add persistent job.
|
||||
*****************************************************************************/
|
||||
int ThreadPoolAddPersistent (ThreadPool*tp,
|
||||
ThreadPoolJob *job,
|
||||
int *jobId);
|
||||
int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolGetAttr
|
||||
@ -307,8 +296,7 @@ int ThreadPoolAddPersistent (ThreadPool*tp,
|
||||
* 0 on success, nonzero on failure
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
int ThreadPoolGetAttr(ThreadPool *tp,
|
||||
ThreadPoolAttr *out);
|
||||
int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolSetAttr
|
||||
*
|
||||
@ -322,8 +310,7 @@ int ThreadPoolGetAttr(ThreadPool *tp,
|
||||
* 0 on success, nonzero on failure
|
||||
* Returns INVALID_POLICY if policy can not be set.
|
||||
*****************************************************************************/
|
||||
int ThreadPoolSetAttr(ThreadPool *tp,
|
||||
ThreadPoolAttr *attr);
|
||||
int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolAdd
|
||||
@ -342,9 +329,7 @@ int ThreadPoolSetAttr(ThreadPool *tp,
|
||||
* 0 on success, nonzero on failure
|
||||
* EOUTOFMEM if not enough memory to add job.
|
||||
*****************************************************************************/
|
||||
int ThreadPoolAdd (ThreadPool*tp,
|
||||
ThreadPoolJob *job,
|
||||
int *jobId);
|
||||
int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolRemove
|
||||
@ -361,8 +346,7 @@ int ThreadPoolAdd (ThreadPool*tp,
|
||||
* 0 on success, nonzero on failure.
|
||||
* INVALID_JOB_ID if job not found.
|
||||
*****************************************************************************/
|
||||
int ThreadPoolRemove(ThreadPool *tp,
|
||||
int jobId, ThreadPoolJob *out);
|
||||
int ThreadPoolRemove(ThreadPool *tp, int jobId, ThreadPoolJob *out);
|
||||
|
||||
|
||||
|
||||
@ -425,7 +409,6 @@ int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
|
||||
*****************************************************************************/
|
||||
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrInit
|
||||
*
|
||||
|
@ -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
@ -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;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# "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
|
||||
@ -11,10 +11,6 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/threadutil/inc \
|
||||
-I$(top_srcdir)/ixml/inc
|
||||
|
||||
AM_CFLAGS = $(PTHREAD_CFLAGS)
|
||||
|
||||
AM_LDFLAGS = $(PTHREAD_LIBS)
|
||||
|
||||
LDADD = \
|
||||
libupnp.la \
|
||||
$(top_builddir)/threadutil/libthreadutil.la \
|
||||
|
@ -9,10 +9,6 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/threadutil/inc \
|
||||
-I$(top_srcdir)/ixml/inc
|
||||
|
||||
AM_CFLAGS = $(PTHREAD_CFLAGS)
|
||||
|
||||
AM_LDFLAGS = $(PTHREAD_LIBS)
|
||||
|
||||
LDADD = \
|
||||
$(top_builddir)/upnp/libupnp.la \
|
||||
$(top_builddir)/threadutil/libthreadutil.la \
|
||||
|
Loading…
x
Reference in New Issue
Block a user