Merge pull request #1308 from dandrader/no-pthread_cancel-on-android
No pthread_cancel() on Android
This commit is contained in:
commit
be09731e4a
5
config.h
5
config.h
@ -61,4 +61,9 @@
|
|||||||
|
|
||||||
#define UNUSED(A) (void)(A)
|
#define UNUSED(A) (void)(A)
|
||||||
|
|
||||||
|
/* Android Bionic libpthread implementation doesn't have pthread_cancel */
|
||||||
|
#ifndef ANDROID
|
||||||
|
# define HAVE_PTHREAD_CANCEL
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -201,11 +201,13 @@ void mosquitto__destroy(struct mosquitto *mosq)
|
|||||||
if(!mosq) return;
|
if(!mosq) return;
|
||||||
|
|
||||||
#ifdef WITH_THREADING
|
#ifdef WITH_THREADING
|
||||||
|
# ifdef HAVE_PTHREAD_CANCEL
|
||||||
if(mosq->threaded == mosq_ts_self && !pthread_equal(mosq->thread_id, pthread_self())){
|
if(mosq->threaded == mosq_ts_self && !pthread_equal(mosq->thread_id, pthread_self())){
|
||||||
pthread_cancel(mosq->thread_id);
|
pthread_cancel(mosq->thread_id);
|
||||||
pthread_join(mosq->thread_id, NULL);
|
pthread_join(mosq->thread_id, NULL);
|
||||||
mosq->threaded = mosq_ts_none;
|
mosq->threaded = mosq_ts_none;
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
if(mosq->id){
|
if(mosq->id){
|
||||||
/* If mosq->id is not NULL then the client has already been initialised
|
/* If mosq->id is not NULL then the client has already been initialised
|
||||||
|
@ -27,7 +27,7 @@ void *mosquitto__thread_main(void *obj);
|
|||||||
|
|
||||||
int mosquitto_loop_start(struct mosquitto *mosq)
|
int mosquitto_loop_start(struct mosquitto *mosq)
|
||||||
{
|
{
|
||||||
#ifdef WITH_THREADING
|
#if defined(WITH_THREADING) && defined(HAVE_PTHREAD_CANCEL)
|
||||||
if(!mosq || mosq->threaded != mosq_ts_none) return MOSQ_ERR_INVAL;
|
if(!mosq || mosq->threaded != mosq_ts_none) return MOSQ_ERR_INVAL;
|
||||||
|
|
||||||
mosq->threaded = mosq_ts_self;
|
mosq->threaded = mosq_ts_self;
|
||||||
@ -43,7 +43,7 @@ int mosquitto_loop_start(struct mosquitto *mosq)
|
|||||||
|
|
||||||
int mosquitto_loop_stop(struct mosquitto *mosq, bool force)
|
int mosquitto_loop_stop(struct mosquitto *mosq, bool force)
|
||||||
{
|
{
|
||||||
#ifdef WITH_THREADING
|
#if defined(WITH_THREADING) && defined(HAVE_PTHREAD_CANCEL)
|
||||||
# ifndef WITH_BROKER
|
# ifndef WITH_BROKER
|
||||||
char sockpair_data = 0;
|
char sockpair_data = 0;
|
||||||
# endif
|
# endif
|
||||||
|
Loading…
Reference in New Issue
Block a user