@ -28,9 +28,9 @@ void *_mosquitto_thread_main(void *obj);
int mosquitto_loop_start ( struct mosquitto * mosq )
{
# ifdef WITH_THREADING
if ( ! mosq | | mosq - > threaded ) return MOSQ_ERR_INVAL ;
if ( ! mosq | | mosq - > threaded ! = mosq_ts_none ) return MOSQ_ERR_INVAL ;
mosq - > threaded = true ;
mosq - > threaded = mosq_ts_self ;
if ( ! pthread_create ( & mosq - > thread_id , NULL , _mosquitto_thread_main , mosq ) ) {
return MOSQ_ERR_SUCCESS ;
} else {
@ -48,7 +48,7 @@ int mosquitto_loop_stop(struct mosquitto *mosq, bool force)
char sockpair_data = 0 ;
# endif
if ( ! mosq | | ! mosq - > threaded ) return MOSQ_ERR_INVAL ;
if ( ! mosq | | mosq - > threaded ! = mosq_ts_self ) return MOSQ_ERR_INVAL ;
/* Write a single byte to sockpairW (connected to sockpairR) to break out
@ -67,7 +67,7 @@ int mosquitto_loop_stop(struct mosquitto *mosq, bool force)
}
pthread_join ( mosq - > thread_id , NULL ) ;
mosq - > thread_id = pthread_self ( ) ;
mosq - > threaded = fals e;
mosq - > threaded = mosq_ts_non e;
return MOSQ_ERR_SUCCESS ;
# else
@ -106,7 +106,11 @@ int mosquitto_threaded_set(struct mosquitto *mosq, bool threaded)
{
if ( ! mosq ) return MOSQ_ERR_INVAL ;
mosq - > threaded = threaded ;
if ( threaded ) {
mosq - > threaded = mosq_ts_external ;
} else {
mosq - > threaded = mosq_ts_none ;
}
return MOSQ_ERR_SUCCESS ;
}