White spaces and code reorganization.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@528 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2010-03-31 17:47:55 +00:00
parent 3fb182aa95
commit 59ec1fd641
6 changed files with 456 additions and 486 deletions

View File

@ -2,47 +2,6 @@
Version 1.8.0 Version 1.8.0
******************************************************************************* *******************************************************************************
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Added API to ithread, created the following functions:
- int ithread_initialize_library(void);
- int ithread_cleanup_library(void);
- int ithread_initialize_thread(void);
- int ithread_cleanup_thread(void);
* SF Bug Tracker [ 2876374 ] Access Violation when compiling with Visual Studio 2008
Submitted: Stulle ( stulleamgym ) - 2009-10-10 19:05
Hi,
I am one of the devs of the MorphXT project and I use this lib in some
other of my projects, too. When I tried to upgrade the lib earlier for one
of my projects I had to realise that something did not work at first and
while most of the things were reasonably ease to be fixed. Now, the last
thing I encountered was not so easy to fix and I am uncertain if my fix is
any good so I'll just post it here and wait for some comments.
The problem was that I got an Access Violation when calling "UpnpInit". It
would call "ithread_rwlock_init(&GlobalHndRWLock, NULL)" which eventually
led to calling "pthread_cond_init" and I got the error notice at
"EnterCriticalSection (&ptw32_cond_list_lock);". It appeared that
"ptw32_cond_list_lock" was NULL. Now, I found two ways to fix this. Firstly
moving the whole block after at least one of the "ThreadPoolInit" calls
will fix the issue. Secondly, you could add:
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
// to get the following working we need this... is it a good patch or
not... I do not know!
pthread_win32_process_attach_np();
#endif
#endif
right before "ithread_rwlock_init(&GlobalHndRWLock, NULL)".
Just so you know, I am using libupnp 1.6.6 and libpthreads 2.8.0 and both
are linked static into the binaries. I am currently using Visual Studio
2008 for development with Windows being the target OS. Any comment at your
end?
Regards, Stulle
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net> 2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Forward port of svn revision 505: * Forward port of svn revision 505:
SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage. SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
@ -234,6 +193,47 @@ Version 1.8.0
Version 1.6.7 Version 1.6.7
******************************************************************************* *******************************************************************************
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Added API to ithread, created the following functions:
- int ithread_initialize_library(void);
- int ithread_cleanup_library(void);
- int ithread_initialize_thread(void);
- int ithread_cleanup_thread(void);
* SF Bug Tracker [ 2876374 ] Access Violation when compiling with Visual Studio 2008
Submitted: Stulle ( stulleamgym ) - 2009-10-10 19:05
Hi,
I am one of the devs of the MorphXT project and I use this lib in some
other of my projects, too. When I tried to upgrade the lib earlier for one
of my projects I had to realise that something did not work at first and
while most of the things were reasonably ease to be fixed. Now, the last
thing I encountered was not so easy to fix and I am uncertain if my fix is
any good so I'll just post it here and wait for some comments.
The problem was that I got an Access Violation when calling "UpnpInit". It
would call "ithread_rwlock_init(&GlobalHndRWLock, NULL)" which eventually
led to calling "pthread_cond_init" and I got the error notice at
"EnterCriticalSection (&ptw32_cond_list_lock);". It appeared that
"ptw32_cond_list_lock" was NULL. Now, I found two ways to fix this. Firstly
moving the whole block after at least one of the "ThreadPoolInit" calls
will fix the issue. Secondly, you could add:
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
// to get the following working we need this... is it a good patch or
not... I do not know!
pthread_win32_process_attach_np();
#endif
#endif
right before "ithread_rwlock_init(&GlobalHndRWLock, NULL)".
Just so you know, I am using libupnp 1.6.6 and libpthreads 2.8.0 and both
are linked static into the binaries. I am currently using Visual Studio
2008 for development with Windows being the target OS. Any comment at your
end?
Regards, Stulle
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net> 2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage. * SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
Submitted By: zephyrus ( zephyrus00jp ) Submitted By: zephyrus ( zephyrus00jp )

View File

@ -285,13 +285,13 @@ static UPNP_INLINE void UpnpDisplayBanner(
*/ */
#ifdef DEBUG #ifdef DEBUG
void PrintThreadPoolStats( void PrintThreadPoolStats(
/* [in] The thread pool. */ /*! [in] The thread pool. */
ThreadPool *tp, ThreadPool *tp,
/* [in] The file name that called this function, use the macro __FILE__. */ /*! [in] The file name that called this function, use the macro __FILE__. */
const char *DbgFileName, const char *DbgFileName,
/* [in] The line number that the function was called, use the macro __LINE__. */ /*! [in] The line number that the function was called, use the macro __LINE__. */
int DbgLineNo, int DbgLineNo,
/* [in] The message. */ /*! [in] The message. */
const char *msg); const char *msg);
#else #else
static UPNP_INLINE void PrintThreadPoolStats( static UPNP_INLINE void PrintThreadPoolStats(
@ -304,6 +304,24 @@ static UPNP_INLINE void PrintThreadPoolStats(
#endif #endif
/*!
* \brief Print the node names and values of a XML tree.
*/
#ifdef DEBUG
void printNodes(
/*! [in] The root of the tree to print. */
IXML_Node *tmpRoot,
/*! [in] The depth to print. */
int depth);
#else
static UPNP_INLINE void printNodes(
IXML_Node *tmpRoot,
int depth)
{
}
#endif
/*@}*/ /*@}*/
#ifdef __cplusplus #ifdef __cplusplus

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@
#include "ithread.h" #include "ithread.h"
#include "ixml.h"
#include "upnp.h" #include "upnp.h"
#include "upnpdebug.h" #include "upnpdebug.h"
@ -64,6 +65,8 @@ static const char *infoFileName = "IUpnpInfoFile.txt";
#ifdef DEBUG #ifdef DEBUG
int UpnpInitLog(void) int UpnpInitLog(void)
{ {
ithread_mutex_init(&GlobalDebugMutex, NULL); ithread_mutex_init(&GlobalDebugMutex, NULL);
@ -108,10 +111,8 @@ void UpnpSetLogFileNames(
infoFileName = InfoFileName; infoFileName = InfoFileName;
} }
} }
#endif /* DEBUG */
#ifdef DEBUG
int DebugAtThisLevel( int DebugAtThisLevel(
Upnp_LogLevel DLevel, Upnp_LogLevel DLevel,
Dbg_Module Module) Dbg_Module Module)
@ -129,10 +130,8 @@ int DebugAtThisLevel(
return ret; return ret;
} }
#endif
#ifdef DEBUG
void UpnpPrintf( void UpnpPrintf(
Upnp_LogLevel DLevel, Upnp_LogLevel DLevel,
Dbg_Module Module, Dbg_Module Module,
@ -171,10 +170,8 @@ void UpnpPrintf(
va_end(ArgList); va_end(ArgList);
ithread_mutex_unlock(&GlobalDebugMutex); ithread_mutex_unlock(&GlobalDebugMutex);
} }
#endif
#ifdef DEBUG
FILE *GetDebugFile(Upnp_LogLevel DLevel, Dbg_Module Module) FILE *GetDebugFile(Upnp_LogLevel DLevel, Dbg_Module Module)
{ {
FILE *ret; FILE *ret;
@ -193,10 +190,8 @@ FILE *GetDebugFile(Upnp_LogLevel DLevel, Dbg_Module Module)
return ret; return ret;
} }
#endif
#ifdef DEBUG
void UpnpDisplayFileAndLine( void UpnpDisplayFileAndLine(
FILE *fd, FILE *fd,
const char *DbgFileName, const char *DbgFileName,
@ -233,10 +228,8 @@ void UpnpDisplayFileAndLine(
UpnpDisplayBanner(fd, lines, NLINES, NUMBER_OF_STARS); UpnpDisplayBanner(fd, lines, NLINES, NUMBER_OF_STARS);
fflush(fd); fflush(fd);
} }
#endif
#ifdef DEBUG
void UpnpDisplayBanner( void UpnpDisplayBanner(
FILE * fd, FILE * fd,
const char **lines, const char **lines,
@ -289,10 +282,8 @@ void UpnpDisplayBanner(
free(rightMargin); free(rightMargin);
free(leftMargin); free(leftMargin);
} }
#endif
#ifdef DEBUG
void PrintThreadPoolStats( void PrintThreadPoolStats(
ThreadPool *tp, ThreadPool *tp,
const char *DbgFileName, const char *DbgFileName,
@ -331,5 +322,34 @@ void PrintThreadPoolStats(
stats.totalWorkTime, stats.totalWorkTime,
stats.totalIdleTime); stats.totalIdleTime);
} }
#endif
void printNodes(IXML_Node *tmpRoot, int depth)
{
int i;
IXML_NodeList *NodeList1;
IXML_Node *ChildNode1;
unsigned short NodeType;
const DOMString NodeValue;
const DOMString NodeName;
NodeList1 = ixmlNode_getChildNodes(tmpRoot);
for (i = 0; i < 100; ++i) {
ChildNode1 = ixmlNodeList_item(NodeList1, i);
if (ChildNode1 == NULL) {
break;
}
printNodes(ChildNode1, depth+1);
NodeType = ixmlNode_getNodeType(ChildNode1);
NodeValue = ixmlNode_getNodeValue(ChildNode1);
NodeName = ixmlNode_getNodeName(ChildNode1);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"DEPTH-%2d-IXML_Node Type %d, "
"IXML_Node Name: %s, IXML_Node Value: %s\n",
depth, NodeType, NodeName, NodeValue);
}
}
#endif /* DEBUG */

View File

@ -69,7 +69,8 @@ typedef enum SsdpSearchType{
/* Enumeration to define all different type of ssdp messages */ /* Enumeration to define all different type of ssdp messages */
typedef enum SsdpCmdType{SSDP_ERROR=-1, typedef enum SsdpCmdType{
SSDP_ERROR=-1,
SSDP_OK, SSDP_OK,
SSDP_ALIVE, SSDP_ALIVE,
SSDP_BYEBYE, SSDP_BYEBYE,

View File

@ -245,60 +245,6 @@ typedef enum {
#define E_HTTP_SYNTAX -6 #define E_HTTP_SYNTAX -6
/*!
* \brief (Windows Only) Initializes the Windows Winsock library.
*
* \return UPNP_E_SUCCESS on success, UPNP_E_INIT_FAILED on failure.
*/
#ifdef WIN32
int WinsockInit();
#endif
/*!
* \brief Performs the initial steps in initializing the UPnP SDK.
*
* \li Winsock library is initialized for the process (Windows specific).
* \li The logging (for debug messages) is initialized.
* \li Mutexes, Handle table and thread pools are allocated and initialized.
* \li Callback functions for SOAP and GENA are set, if they're enabled.
* \li The SDK timer thread is initialized.
*
* \return UPNP_E_SUCCESS on success.
*/
int UpnpInitPreamble();
/*!
* \brief Initializes the global mutexes used by the UPnP SDK.
*
* \return UPNP_E_SUCCESS on success or UPNP_E_INIT_FAILED if a mutex could not
* be initialized.
*/
int UpnpInitMutexes();
/*!
* \brief Initializes the global threadm pools used by the UPnP SDK.
*
* \return UPNP_E_SUCCESS on success or UPNP_E_INIT_FAILED if a mutex could not
* be initialized.
*/
int UpnpInitThreadPools();
/*!
* \brief Finishes initializing the UPnP SDK.
* \li The MiniServer is started, if enabled.
* \li The WebServer is started, if enabled.
*
* \return UPNP_E_SUCCESS on success or UPNP_E_INIT_FAILED if a mutex could not
* be initialized.
*/
int UpnpInitStartServers(
/*! [in] Local Port to listen for incoming connections. */
unsigned short DestPort);
/*! /*!
* \brief Retrieve interface information and keep it in global variables. * \brief Retrieve interface information and keep it in global variables.
* If NULL, we'll find the first suitable interface for operation. * If NULL, we'll find the first suitable interface for operation.