Quit config watcher thread if it fails to init and clean up

pull/109/head
jackun 4 years ago
parent 82243bf115
commit 841d76c6af
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -17,6 +17,12 @@ void *fileChanged(void *params_void){
char buffer[EVENT_BUF_LEN];
fd = inotify_init();
wd = inotify_add_watch( fd, nt->params->config_file_path.c_str(), IN_MODIFY);
if (wd < 0) {
close(fd);
return nullptr;
}
while (!nt->quit) {
length = read( fd, buffer, EVENT_BUF_LEN );
while (i < length) {
@ -31,5 +37,7 @@ void *fileChanged(void *params_void){
i = 0;
printf("File Changed\n");
}
return NULL;
}
inotify_rm_watch(fd, wd);
close(fd);
return nullptr;
}

Loading…
Cancel
Save