mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
cmdmqtt: avoid using pthread_cancel, for compatibility with termux
This commit is contained in:
parent
8f9bb379ad
commit
53595e0a3a
1 changed files with 5 additions and 4 deletions
|
@ -59,20 +59,21 @@ static void mqtt_publish_callback(void **unused, struct mqtt_response_publish *p
|
||||||
free(topic_name);
|
free(topic_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static volatile int mqtt_client_should_exit = 0;
|
||||||
|
|
||||||
static void *mqtt_client_refresher(void *client) {
|
static void *mqtt_client_refresher(void *client) {
|
||||||
while (1) {
|
while (!mqtt_client_should_exit) {
|
||||||
pthread_testcancel(); // check if we cancelled
|
|
||||||
mqtt_sync((struct mqtt_client *) client);
|
mqtt_sync((struct mqtt_client *) client);
|
||||||
msleep(100);
|
msleep(100);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mqtt_exit(int status, mqtt_pal_socket_handle sockfd, pthread_t *client_daemon) {
|
static int mqtt_exit(int status, mqtt_pal_socket_handle sockfd, pthread_t *client_daemon) {
|
||||||
close_nb_socket(sockfd);
|
close_nb_socket(sockfd);
|
||||||
if (client_daemon != NULL) {
|
if (client_daemon != NULL) {
|
||||||
pthread_cancel(*client_daemon);
|
mqtt_client_should_exit = 1;
|
||||||
pthread_join(*client_daemon, NULL); // Wait for the thread to finish
|
pthread_join(*client_daemon, NULL); // Wait for the thread to finish
|
||||||
|
mqtt_client_should_exit = 0;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue