From 0e287a87bef8fc5613de0ab00262cc9424b9638b Mon Sep 17 00:00:00 2001 From: Olga Kornievskaia Date: Thu, 25 Aug 2011 12:17:17 -0400 Subject: [PATCH] simplifying logic in handle_readdir --- daemon/readdir.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/daemon/readdir.c b/daemon/readdir.c index a8ca3fe..811c254 100644 --- a/daemon/readdir.c +++ b/daemon/readdir.c @@ -463,27 +463,20 @@ static int handle_readdir(nfs41_upcall *upcall) args->buf = NULL; args->query_reply_len = 0; - if (state->cookie.cookie) { /* cookie exists */ - if (args->restart) { + if (args->initial || args->restart) { + ZeroMemory(&state->cookie, sizeof(nfs41_readdir_cookie)); + if (!state->cookie.cookie) + dprintf(1, "initializing the 1st readdir cookie\n"); + else if (args->restart) dprintf(1, "restarting; clearing previous cookie %llu\n", state->cookie.cookie); - ZeroMemory(&state->cookie, sizeof(nfs41_readdir_cookie)); - } else if (args->initial) { /* shouldn't happen */ + else if (args->initial) dprintf(1, "*** initial; clearing previous cookie %llu!\n", state->cookie.cookie); - ZeroMemory(&state->cookie, sizeof(nfs41_readdir_cookie)); - } else - dprintf(1, "resuming enumeration with cookie %llu.\n", - state->cookie.cookie); - } else { /* cookie is null */ - if (args->initial || args->restart) { - dprintf(1, "initializing the 1st readdir cookie\n"); - ZeroMemory(&state->cookie, sizeof(nfs41_readdir_cookie)); - } else { - dprintf(1, "handle_nfs41_readdir: EOF\n"); - status = ERROR_NO_MORE_FILES; - goto out; - } + } else if (!state->cookie.cookie) { + dprintf(1, "handle_nfs41_readdir: EOF\n"); + status = ERROR_NO_MORE_FILES; + goto out; } entry_buf = malloc(max(args->buf_len, 4096));