From a67c054ef76fb698b449e575c1e18d4fdc53ee6c Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Thu, 30 Apr 2009 23:58:27 +0000 Subject: [PATCH] * Properly skip sorting on UPnPSearches of very large containers on sparc-based ReadyNAS processors. --- LICENCE | 2 +- genconfig.sh | 20 +++++++++++++++----- upnpsoap.c | 18 +++++++++--------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/LICENCE b/LICENCE index c4b67fa..fb2a7fa 100644 --- a/LICENCE +++ b/LICENCE @@ -1,6 +1,6 @@ MiniDLNA is distributed under version 2 of the General Public License (included in its entirety, below). Version 2 is the only version of this license which -this version of BusyBox (or modified versions derived from this one) may be +this version of MiniDLNA (or modified versions derived from this one) may be distributed under. ------------------------------------------------------------------------ diff --git a/genconfig.sh b/genconfig.sh index fa84fcc..c94d639 100755 --- a/genconfig.sh +++ b/genconfig.sh @@ -16,6 +16,8 @@ DB_PATH="/tmp/minidlna" # detecting the OS name and version OS_NAME=`uname -s` OS_VERSION=`uname -r` +TIVO="/*#define TIVO_SUPPORT*/" +READYNAS="/*#define READYNAS*/" ${RM} ${CONFIGFILE} @@ -34,7 +36,7 @@ ${RM} ${CONFIGFILE} ! -e "/usr/include/ffmpeg/libavutil/avutil.h" ] && MISSING="libavutil $MISSING" [ ! -e "/usr/include/ffmpeg/avformat.h" -a \ ! -e "/usr/include/libavformat/avformat.h" -a \ - ! -e "/usr/include/ffmpeg/libavformat/avformat.h" ] && MISSING="libformat $MISSING" + ! -e "/usr/include/ffmpeg/libavformat/avformat.h" ] && MISSING="libavformat $MISSING" [ ! -e "/usr/include/ffmpeg/avcodec.h" -a \ ! -e "/usr/include/libavcodec/avcodec.h" -a \ ! -e "/usr/include/ffmpeg/libavcodec/avcodec.h" ] && MISSING="libavcodec $MISSING" @@ -100,8 +102,16 @@ case $OS_NAME in KERNVERC=`echo $OS_VERSION | awk -F. '{print $3}'` KERNVERD=`echo $OS_VERSION | awk -F. '{print $4}'` #echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD" + # NETGEAR ReadyNAS special case + if [ -f /etc/raidiator_version ]; then + OS_NAME=$(awk -F'!!|=' '{ print $1 }' /etc/raidiator_version) + OS_VERSION=$(awk -F'!!|[=,]' '{ print $3 }' /etc/raidiator_version) + OS_URL=http://www.readynas.com/ + DB_PATH="/var/cache/minidlna" + TIVO="#define TIVO_SUPPORT" + READYNAS="#define READYNAS" # Debian GNU/Linux special case - if [ -f /etc/debian_version ]; then + elif [ -f /etc/debian_version ]; then OS_NAME=Debian OS_VERSION=`cat /etc/debian_version` OS_URL=http://www.debian.org/ @@ -112,11 +122,9 @@ case $OS_NAME in OS_NAME=`${LSB_RELEASE} -i -s` OS_VERSION=`${LSB_RELEASE} -r -s` fi - echo "#define USE_NETFILTER 1" >> ${CONFIGFILE} ;; *) echo "Unknown OS : $OS_NAME" - echo "Please contact the author at http://miniupnp.free.fr/" exit 1 ;; esac @@ -144,7 +152,9 @@ fi echo "" >> ${CONFIGFILE} echo "/* Enable NETGEAR ReadyNAS-specific tweaks. */" >> ${CONFIGFILE} -echo "/*#define READYNAS*/" >> ${CONFIGFILE} +echo "${READYNAS}" >> ${CONFIGFILE} +echo "/* Compile in TiVo support. */" >> ${CONFIGFILE} +echo "${TIVO}" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE} echo "#endif" >> ${CONFIGFILE} diff --git a/upnpsoap.c b/upnpsoap.c index 91b3f9f..172089d 100644 --- a/upnpsoap.c +++ b/upnpsoap.c @@ -639,11 +639,6 @@ BrowseContentDirectory(struct upnphttp * h, const char * action) if( !RequestedCount ) RequestedCount = -1; -#ifdef __sparc__ /* Sorting takes too long on slow processors with very large containers */ - if( totalMatches < 10000 ) -#endif - orderBy = parse_sort_criteria(SortCriteria); - args.resp = resp; args.size = sprintf(resp, "%s", resp0); @@ -699,6 +694,11 @@ BrowseContentDirectory(struct upnphttp * h, const char * action) totalMatches = atoi(result[1]); sqlite3_free_table(result); } +#ifdef __sparc__ /* Sorting takes too long on slow processors with very large containers */ + if( totalMatches < 10000 ) +#endif + orderBy = parse_sort_criteria(SortCriteria); + sql = sqlite3_mprintf( SELECT_COLUMNS "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)" " where PARENT_ID = '%s' %s limit %d, %d;", @@ -767,10 +767,6 @@ SearchContentDirectory(struct upnphttp * h, const char * action) if( !RequestedCount ) RequestedCount = -1; -#ifdef __sparc__ /* Sorting takes too long on slow processors with very large containers */ - if( totalMatches < 10000 ) -#endif - orderBy = parse_sort_criteria(SortCriteria); args.resp = resp; args.size = sprintf(resp, "%s", resp0); @@ -872,6 +868,10 @@ SearchContentDirectory(struct upnphttp * h, const char * action) totalMatches = atoi(result[1]); sqlite3_free_table(result); } +#ifdef __sparc__ /* Sorting takes too long on slow processors with very large containers */ + if( totalMatches < 10000 ) +#endif + orderBy = parse_sort_criteria(SortCriteria); sql = sqlite3_mprintf( SELECT_COLUMNS "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"