GlobalHndMutex, which was a mutex is now GlobalHndRWLock, which is a
rwlock. HandleLock() is mapped to HandleWriteLock() while all other instances have not been checked. One instance in AdvertiseAndReply() has been changed to HandleReadLock(). Thanks to Alex (afaucher) for the bug report and suggestions. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@233 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
83ee32afb7
commit
f87dbf8115
@ -2,6 +2,13 @@
|
|||||||
Version 1.6.1
|
Version 1.6.1
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2007-11-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* GlobalHndMutex, which was a mutex is now GlobalHndRWLock, which is a
|
||||||
|
rwlock. HandleLock() is mapped to HandleWriteLock() while all other
|
||||||
|
instances have not been checked. One instance in AdvertiseAndReply()
|
||||||
|
has been changed to HandleReadLock(). Thanks to Alex (afaucher) for the
|
||||||
|
bug report and suggestions.
|
||||||
|
|
||||||
2007-11-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-11-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* Added support for rwlocks.
|
* Added support for rwlocks.
|
||||||
|
|
||||||
|
3
THANKS
3
THANKS
@ -6,6 +6,7 @@ suggesting various improvements or submitting actual code.
|
|||||||
Here is a list of these people. Help us keep it complete and
|
Here is a list of these people. Help us keep it complete and
|
||||||
exempt of errors.
|
exempt of errors.
|
||||||
|
|
||||||
|
- Alex (afaucher)
|
||||||
- Arno Willig
|
- Arno Willig
|
||||||
- Bob Ciora
|
- Bob Ciora
|
||||||
- Chaos
|
- Chaos
|
||||||
@ -24,7 +25,7 @@ exempt of errors.
|
|||||||
- Leuk_He
|
- Leuk_He
|
||||||
- Loigu
|
- Loigu
|
||||||
- Luke Kim
|
- Luke Kim
|
||||||
- Marcelo Roberto Jimenez
|
- Marcelo Roberto Jimenez (mroberto)
|
||||||
- Markus Strobl
|
- Markus Strobl
|
||||||
- Nektarios K. Papadopoulos
|
- Nektarios K. Papadopoulos
|
||||||
- Oskar Liljeblad
|
- Oskar Liljeblad
|
||||||
|
@ -84,8 +84,8 @@ virtualDirList *pVirtualDirList;
|
|||||||
// Mutex to synchronize the subscription handling at the client side
|
// Mutex to synchronize the subscription handling at the client side
|
||||||
CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; )
|
CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; )
|
||||||
|
|
||||||
//Mutex to synchronize handles ( root device or control point handle)
|
// rwlock to synchronize handles (root device or control point handle)
|
||||||
ithread_mutex_t GlobalHndMutex;
|
ithread_rwlock_t GlobalHndRWLock;
|
||||||
|
|
||||||
// Mutex to synchronize the uuid creation process
|
// Mutex to synchronize the uuid creation process
|
||||||
ithread_mutex_t gUUIDMutex;
|
ithread_mutex_t gUUIDMutex;
|
||||||
@ -213,26 +213,26 @@ int UpnpInit( IN const char *HostIP,
|
|||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
/* On Cygwin, pthread_mutex_init() fails without this memset. */
|
/* On Cygwin, pthread_mutex_init() fails without this memset. */
|
||||||
/* TODO: Fix Cygwin so we don't need this memset(). */
|
/* TODO: Fix Cygwin so we don't need this memset(). */
|
||||||
memset(&GlobalHndMutex, 0, sizeof(GlobalHndMutex));
|
memset(&GlobalHndRWLock, 0, sizeof(GlobalHndRWLock));
|
||||||
#endif
|
#endif
|
||||||
if( ithread_mutex_init( &GlobalHndMutex, NULL ) != 0 ) {
|
if (ithread_rwlock_init(&GlobalHndRWLock, NULL) != 0) {
|
||||||
return UPNP_E_INIT_FAILED;
|
return UPNP_E_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ithread_mutex_init( &gUUIDMutex, NULL ) != 0 ) {
|
if (ithread_mutex_init(&gUUIDMutex, NULL) != 0) {
|
||||||
return UPNP_E_INIT_FAILED;
|
return UPNP_E_INIT_FAILED;
|
||||||
}
|
}
|
||||||
// initialize subscribe mutex
|
// initialize subscribe mutex
|
||||||
#ifdef INCLUDE_CLIENT_APIS
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
if ( ithread_mutex_init( &GlobalClientSubscribeMutex, NULL ) != 0 ) {
|
if (ithread_mutex_init(&GlobalClientSubscribeMutex, NULL) != 0) {
|
||||||
return UPNP_E_INIT_FAILED;
|
return UPNP_E_INIT_FAILED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HandleLock();
|
HandleLock();
|
||||||
if( HostIP != NULL )
|
if( HostIP != NULL ) {
|
||||||
strcpy( LOCAL_HOST, HostIP );
|
strcpy( LOCAL_HOST, HostIP );
|
||||||
else {
|
} else {
|
||||||
if( getlocalhostname( LOCAL_HOST ) != UPNP_E_SUCCESS ) {
|
if( getlocalhostname( LOCAL_HOST ) != UPNP_E_SUCCESS ) {
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
return UPNP_E_INIT_FAILED;
|
return UPNP_E_INIT_FAILED;
|
||||||
@ -447,7 +447,7 @@ UpnpFinish()
|
|||||||
#ifdef INCLUDE_CLIENT_APIS
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
ithread_mutex_destroy(&GlobalClientSubscribeMutex);
|
ithread_mutex_destroy(&GlobalClientSubscribeMutex);
|
||||||
#endif
|
#endif
|
||||||
ithread_mutex_destroy(&GlobalHndMutex);
|
ithread_rwlock_destroy(&GlobalHndRWLock);
|
||||||
ithread_mutex_destroy(&gUUIDMutex);
|
ithread_mutex_destroy(&gUUIDMutex);
|
||||||
|
|
||||||
// remove all virtual dirs
|
// remove all virtual dirs
|
||||||
|
@ -98,18 +98,25 @@ struct Handle_Info
|
|||||||
int aliasInstalled; // 0 = not installed; otherwise installed
|
int aliasInstalled; // 0 = not installed; otherwise installed
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ithread_mutex_t GlobalHndMutex;
|
extern ithread_rwlock_t GlobalHndRWLock;
|
||||||
Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo);
|
Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo);
|
||||||
|
|
||||||
#define HandleLock() \
|
#define HandleLock() HandleWriteLock()
|
||||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying Lock"); \
|
|
||||||
ithread_mutex_lock(&GlobalHndMutex); \
|
#define HandleWriteLock() \
|
||||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "LOCK");
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying a write lock"); \
|
||||||
|
ithread_rwlock_wrlock(&GlobalHndRWLock); \
|
||||||
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Write lock acquired");
|
||||||
|
|
||||||
|
#define HandleReadLock() \
|
||||||
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying a read lock"); \
|
||||||
|
ithread_rwlock_rdlock(&GlobalHndRWLock); \
|
||||||
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Read lock acquired");
|
||||||
|
|
||||||
#define HandleUnlock() \
|
#define HandleUnlock() \
|
||||||
UpnpPrintf(UPNP_INFO, API,__FILE__, __LINE__, "Trying Unlock"); \
|
UpnpPrintf(UPNP_INFO, API,__FILE__, __LINE__, "Trying Unlock"); \
|
||||||
ithread_mutex_unlock(&GlobalHndMutex); \
|
ithread_rwlock_unlock(&GlobalHndRWLock); \
|
||||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Unlock");
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Unlocked rwlock");
|
||||||
|
|
||||||
Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out,
|
Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out,
|
||||||
struct Handle_Info **HndInfo);
|
struct Handle_Info **HndInfo);
|
||||||
|
@ -122,16 +122,13 @@ int AdvertiseAndReply( IN int AdFlag,
|
|||||||
"Inside AdvertiseAndReply with AdFlag = %d\n",
|
"Inside AdvertiseAndReply with AdFlag = %d\n",
|
||||||
AdFlag );
|
AdFlag );
|
||||||
|
|
||||||
HandleLock();
|
// Use a read lock
|
||||||
|
HandleReadLock();
|
||||||
if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) {
|
if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) {
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
return UPNP_E_INVALID_HANDLE;
|
return UPNP_E_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
defaultExp = SInfo->MaxAge;
|
defaultExp = SInfo->MaxAge;
|
||||||
|
|
||||||
//Modifed to prevent more than one thread from accessing the
|
|
||||||
//UpnpDocument stored with the handle at the same time
|
|
||||||
// HandleUnlock();
|
|
||||||
nodeList = NULL;
|
nodeList = NULL;
|
||||||
|
|
||||||
//get server info
|
//get server info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user