[config] keep pthread_t pointers in notify_thread struct for MT safety

pull/109/head
jackun 4 years ago
parent 1b192c4910
commit d3f895cbef
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -1,4 +1,3 @@
#include <thread>
#include <chrono>
#include <unistd.h>
#include <fcntl.h>
@ -7,8 +6,6 @@
#include "config.h"
#include "notify.h"
pthread_t fileChange;
#define EVENT_SIZE ( sizeof (struct inotify_event) )
#define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
@ -50,7 +47,7 @@ bool start_notifier(notify_thread& nt)
return false;
}
pthread_create(&fileChange, NULL, &fileChanged, &nt);
pthread_create(&nt.thread, NULL, &fileChanged, &nt);
return true;
}
@ -65,5 +62,5 @@ void stop_notifier(notify_thread& nt)
close(nt.fd);
nt.fd = -1;
pthread_join(fileChange, nullptr);
pthread_join(nt.thread, nullptr);
}

@ -1,3 +1,4 @@
#include <thread>
#include <mutex>
#include "overlay_params.h"
@ -7,6 +8,7 @@ struct notify_thread
overlay_params *params = nullptr;
bool quit = false;
std::mutex mutex;
pthread_t thread;
};
bool start_notifier(notify_thread& nt);

Loading…
Cancel
Save