some logger changes
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "array/array.h"
|
||||
#include "array/sc_array.h"
|
||||
#include "common.h"
|
||||
#include "filewatch.h"
|
||||
#include "filewatch_context.h"
|
||||
@@ -85,8 +86,8 @@ static hiFileEvent file_event_create(const struct inotify_event *inevent,
|
||||
size_t fullpath_size = parent_name_size + event_path_size;
|
||||
if (fullpath_size > BUFSIZE - 1) {
|
||||
sc_log_error("Pathname length over %u, please compile with smaller "
|
||||
"paths. Event discarded for %s\n.", BUFSIZE - 1,
|
||||
inevent->name);
|
||||
"paths. Event discarded for %s\n.",
|
||||
BUFSIZE - 1, inevent->name);
|
||||
return NULL_EVENT;
|
||||
}
|
||||
#undef BUFSIZE
|
||||
@@ -124,7 +125,8 @@ static hiFileEvent file_event_create(const struct inotify_event *inevent,
|
||||
return NULL_EVENT;
|
||||
}
|
||||
|
||||
event.pathname = watched_file;
|
||||
// Use params path pointer, because that's what user has control over.
|
||||
event.pathname = params->path;
|
||||
|
||||
// Event matched and we're watching for it
|
||||
return event;
|
||||
@@ -137,14 +139,16 @@ static hiFileEvent file_event_create(const struct inotify_event *inevent,
|
||||
return NULL_EVENT;
|
||||
}
|
||||
|
||||
hiFileEvent hi_file_event_pop(hiFileWatcher *ctx) {
|
||||
mtx_lock(&ctx->mutex);
|
||||
hiFileEvent *last = &sc_array_last(&ctx->events);
|
||||
hiFileEvent e = *last;
|
||||
hiFileEvent hi_file_event_pop(hiFileWatcher *fw) {
|
||||
mtx_lock(&fw->mutex);
|
||||
|
||||
sc_array_del_last(&ctx->events);
|
||||
hiFileEvent e = NULL_EVENT;
|
||||
if (sc_array_size(&fw->events) > 0) {
|
||||
e = sc_array_last(&fw->events);
|
||||
sc_array_del_last(&fw->events);
|
||||
}
|
||||
|
||||
mtx_unlock(&ctx->mutex);
|
||||
mtx_unlock(&fw->mutex);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user