diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-03-01 14:07:38 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-03-01 14:07:38 (GMT) |
commit | 1191bd7af1f78db7b8e6d0bd174df360d5c1407d (patch) | |
tree | 98c502fde4137957bf5607f2f7e257d15681133d | |
parent | 2e00f02112fa92533d75757464ff1683691eebbd (diff) | |
download | CMake-1191bd7af1f78db7b8e6d0bd174df360d5c1407d.zip CMake-1191bd7af1f78db7b8e6d0bd174df360d5c1407d.tar.gz CMake-1191bd7af1f78db7b8e6d0bd174df360d5c1407d.tar.bz2 |
ENH: Attempt to remove threading code
-rw-r--r-- | Utilities/cmxmlrpc/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_authcookie.c | 2 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_config.h.in | 2 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_curl_transport.c | 35 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_pthreads.h | 4 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_transport.h | 6 |
6 files changed, 46 insertions, 7 deletions
diff --git a/Utilities/cmxmlrpc/CMakeLists.txt b/Utilities/cmxmlrpc/CMakeLists.txt index 07f4a42..bb878f7 100644 --- a/Utilities/cmxmlrpc/CMakeLists.txt +++ b/Utilities/cmxmlrpc/CMakeLists.txt @@ -47,6 +47,10 @@ SET(HAVE_LIBWWW_SSL) SET(DIRECTORY_SEPARATOR "/") FIND_PACKAGE(Threads) +SET(HAVE_PTHREADS) +IF(WIN32 OR CMAKE_USE_PTHREADS_INIT) + SET(HAVE_PTHREADS 1) +ENDIF(WIN32 OR CMAKE_USE_PTHREADS_INIT) INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/Utilities/cmxmlrpc/xmlrpc_authcookie.c b/Utilities/cmxmlrpc/xmlrpc_authcookie.c index 83541b9..1da929f 100644 --- a/Utilities/cmxmlrpc/xmlrpc_authcookie.c +++ b/Utilities/cmxmlrpc/xmlrpc_authcookie.c @@ -51,7 +51,7 @@ void xmlrpc_authcookie_set ( xmlrpc_env *env, sprintf(unencoded, "%s:%s", username, password); /* Create encoded string. */ - token = xmlrpc_base64_encode_without_newlines(env, unencoded, + token = xmlrpc_base64_encode_without_newlines(env, (unsigned char*)unencoded, strlen(unencoded)); XMLRPC_FAIL_IF_FAULT(env); diff --git a/Utilities/cmxmlrpc/xmlrpc_config.h.in b/Utilities/cmxmlrpc/xmlrpc_config.h.in index fff0e9d..af637c3 100644 --- a/Utilities/cmxmlrpc/xmlrpc_config.h.in +++ b/Utilities/cmxmlrpc/xmlrpc_config.h.in @@ -30,6 +30,8 @@ #define DIRECTORY_SEPARATOR "@DIRECTORY_SEPARATOR@" +#cmakedefine HAVE_PTHREADS @HAVE_PTHREADS@ + /* Xmlrpc-c code uses __inline__ to declare functions that should be compiled as inline code. GNU C recognizes the __inline__ keyword. Others recognize 'inline' or '__inline' or nothing at all to say diff --git a/Utilities/cmxmlrpc/xmlrpc_curl_transport.c b/Utilities/cmxmlrpc/xmlrpc_curl_transport.c index e98353e..c4a5e19 100644 --- a/Utilities/cmxmlrpc/xmlrpc_curl_transport.c +++ b/Utilities/cmxmlrpc/xmlrpc_curl_transport.c @@ -22,7 +22,10 @@ #include <string.h> #include <stdlib.h> #include <errno.h> -#include "xmlrpc_pthreads.h" + +#if defined(HAVE_PTHREADS) +# include "xmlrpc_pthreads.h" +#endif #include <curl/curl.h> #include <curl/types.h> @@ -143,7 +146,6 @@ initWindowsStuff(xmlrpc_env * const envP) { } - static void create(xmlrpc_env * const envP, int const flags ATTR_UNUSED, @@ -163,7 +165,9 @@ create(xmlrpc_env * const envP, envP, XMLRPC_INTERNAL_ERROR, "Unable to allocate transport descriptor."); else { +#ifdef HAVE_PTHREADS pthread_mutex_init(&transportP->listLock, NULL); +#endif list_make_empty(&transportP->rpcList); @@ -183,7 +187,6 @@ create(xmlrpc_env * const envP, } - static void termWindowStuff(void) { @@ -203,7 +206,9 @@ destroy(struct clientTransport * const clientTransportP) { XMLRPC_ASSERT(list_is_empty(&clientTransportP->rpcList)); +#if defined(HAVE_PTHREADS) pthread_mutex_destroy(&clientTransportP->listLock); +#endif curl_global_cleanup(); @@ -428,7 +433,7 @@ doAsyncRpc(void * arg) { #endif - +#if defined(HAVE_PTHREADS) static void createRpcThread(xmlrpc_env * const envP, rpc * const rpcP, @@ -462,6 +467,7 @@ createRpcThread(xmlrpc_env * const envP, break; } } +#endif @@ -493,15 +499,23 @@ rpcCreate(xmlrpc_env * const envP, &rpcP->curlTransactionP); if (!envP->fault_occurred) { if (complete) { +#if defined(HAVE_PTHREADS) createRpcThread(envP, rpcP, &rpcP->thread); +#else + abort(); +#endif if (!envP->fault_occurred) rpcP->threadExists = TRUE; } if (!envP->fault_occurred) { list_init_header(&rpcP->link, rpcP); +#if defined(HAVE_PTHREADS) pthread_mutex_lock(&clientTransportP->listLock); +#endif list_add_head(&clientTransportP->rpcList, &rpcP->link); +#if defined(HAVE_PTHREADS) pthread_mutex_unlock(&clientTransportP->listLock); +#endif } if (envP->fault_occurred) destroyCurlTransaction(rpcP->curlTransactionP); @@ -513,7 +527,6 @@ rpcCreate(xmlrpc_env * const envP, } - static void rpcDestroy(rpc * const rpcP) { @@ -573,7 +586,11 @@ finishRpc(struct list_head * const headerP, void *status; int result; +#if defined(HAVE_PTHREADS) result = pthread_join(rpcP->thread, &status); +#else + abort(); +#endif rpcP->threadExists = FALSE; } @@ -601,11 +618,19 @@ finishAsynch(struct clientTransport * const clientTransportP ATTR_UNUSED, to set an alarm and interrupt running threads. */ +#if defined(HAVE_PTHREADS) pthread_mutex_lock(&clientTransportP->listLock); +#else + abort(); +#endif list_foreach(&clientTransportP->rpcList, finishRpc, NULL); +#if defined(HAVE_PTHREADS) pthread_mutex_unlock(&clientTransportP->listLock); +#else + abort(); +#endif } diff --git a/Utilities/cmxmlrpc/xmlrpc_pthreads.h b/Utilities/cmxmlrpc/xmlrpc_pthreads.h index dfb29c7..31d4049 100644 --- a/Utilities/cmxmlrpc/xmlrpc_pthreads.h +++ b/Utilities/cmxmlrpc/xmlrpc_pthreads.h @@ -26,6 +26,10 @@ #ifndef xmlrpc_pthreads_h_ #define xmlrpc_pthreads_h_ +#if !defined(HAVE_PTHREADS) +# error This system does not have PThreads +#endif + #ifndef WIN32 # define _REENTRANT # include <pthread.h> diff --git a/Utilities/cmxmlrpc/xmlrpc_transport.h b/Utilities/cmxmlrpc/xmlrpc_transport.h index e84832f..1a45166 100644 --- a/Utilities/cmxmlrpc/xmlrpc_transport.h +++ b/Utilities/cmxmlrpc/xmlrpc_transport.h @@ -6,7 +6,9 @@ extern "C" { #endif -#include "xmlrpc_pthreads.h" /* For threading helpers. */ +#if defined(HAVE_PTHREADS) +# include "xmlrpc_pthreads.h" /* For threading helpers. */ +#endif struct call_info; @@ -67,6 +69,7 @@ struct clientTransportOps { ** Transport Helper Functions and declarations. **========================================================================= */ +#if defined(HAVE_PTHREADS) typedef struct _running_thread_info { struct _running_thread_info * Next; @@ -90,6 +93,7 @@ void register_asynch_thread (running_thread_list *list, pthread_t *thread); /* MRB-WARNING: Only call when you have successfully ** acquired the Lock/Unlock mutex! */ void unregister_asynch_thread (running_thread_list *list, pthread_t *thread); +#endif #ifdef __cplusplus |