From c6a27340107854bbcd48ef0a83ee7d3be807445f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 4 Apr 2014 21:12:06 +0200 Subject: [PATCH] smbd: Sort notify events by timestamp This will fix the raw.notify test with the new messaging system. With the new messaging system messages come in via yet another fd that has to line up in poll next to the incoming client TCP socket. With the signal-based messaging messages were always handled before client requests. The new scheme means that notify messages might be deferred a bit (something which can happen in a cluster already now), which then means that notify_marshall_changes() will coalesce entries, which in turn makes raw.notify unhappy. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/smbd/notify.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c index b8085dd6c42..dd4dc1ad4b8 100644 --- a/source3/smbd/notify.c +++ b/source3/smbd/notify.c @@ -170,6 +170,14 @@ static bool notify_marshall_changes(int num_changes, return True; } +static int compare_notify_change_events(const void *p1, const void *p2) +{ + const struct notify_change_event *e1 = p1; + const struct notify_change_event *e2 = p2; + + return timespec_compare(&e1->when, &e2->when); +} + /**************************************************************************** Setup the common parts of the return packet and send it. *****************************************************************************/ @@ -194,6 +202,14 @@ void change_notify_reply(struct smb_request *req, return; } + /* + * Sort the notifies by timestamp when the event happened to avoid + * coalescing and thus dropping events in notify_marshall_changes. + */ + + qsort(notify_buf->changes, notify_buf->num_changes, + sizeof(*(notify_buf->changes)), compare_notify_change_events); + if (!notify_marshall_changes(notify_buf->num_changes, max_param, notify_buf->changes, &blob)) { /* -- 2.11.4.GIT