mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-02-06 02:52:07 +08:00
Windows build fixes.
This commit is contained in:
@@ -117,7 +117,10 @@ struct mosquitto *mosquitto_new(const char *id, bool clean_start, void *userdata
|
||||
if(mosq){
|
||||
mosq->sock = INVALID_SOCKET;
|
||||
#ifdef WITH_THREADING
|
||||
# ifndef WIN32
|
||||
/* Windows doesn't have pthread_cancel, so no need to record self */
|
||||
mosq->thread_id = pthread_self();
|
||||
# endif
|
||||
#endif
|
||||
mosq->sockpairR = INVALID_SOCKET;
|
||||
mosq->sockpairW = INVALID_SOCKET;
|
||||
@@ -217,7 +220,11 @@ int mosquitto_reinitialise(struct mosquitto *mosq, const char *id, bool clean_st
|
||||
pthread_mutex_init(&mosq->msgs_in.mutex, NULL);
|
||||
pthread_mutex_init(&mosq->msgs_out.mutex, NULL);
|
||||
pthread_mutex_init(&mosq->mid_mutex, NULL);
|
||||
#ifdef WIN32
|
||||
mosq->thread_id = NULL;
|
||||
#else
|
||||
mosq->thread_id = pthread_self();
|
||||
#endif
|
||||
#endif
|
||||
if(mosq->disable_socketpair == false){
|
||||
/* This must be after pthread_mutex_init(), otherwise the log mutex may be
|
||||
|
||||
@@ -329,11 +329,7 @@ struct mosquitto {
|
||||
pthread_mutex_t out_packet_mutex;
|
||||
pthread_mutex_t state_mutex;
|
||||
pthread_mutex_t mid_mutex;
|
||||
#ifdef WIN32
|
||||
int thread_id;
|
||||
#else
|
||||
pthread_t thread_id;
|
||||
#endif
|
||||
#endif
|
||||
bool clean_start;
|
||||
time_t session_expiry_time;
|
||||
|
||||
@@ -87,7 +87,11 @@ int mosquitto_loop_stop(struct mosquitto *mosq, bool force)
|
||||
}
|
||||
#endif
|
||||
pthread_join(mosq->thread_id, NULL);
|
||||
#ifdef WIN32
|
||||
mosq->thread_id = NULL;
|
||||
#else
|
||||
mosq->thread_id = pthread_self();
|
||||
#endif
|
||||
mosq->threaded = mosq_ts_none;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
|
||||
@@ -33,6 +33,7 @@ typedef void pthread_condattr_t;
|
||||
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
|
||||
int pthread_join(pthread_t thread, void **retval);
|
||||
int pthread_self(void);
|
||||
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
|
||||
int pthread_mutex_destroy(pthread_mutex_t *mutex);
|
||||
int pthread_mutex_lock(pthread_mutex_t *mutex);
|
||||
|
||||
Reference in New Issue
Block a user