ENH: Attempt to remove threading code
This commit is contained in:
parent
2e00f02112
commit
1191bd7af1
|
@ -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}"
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
|
Loading…
Reference in New Issue