From 98756c2608f0879a2322919c7441973216565272 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 13 Feb 2011 22:38:01 +0100 Subject: cache: close commit request if we already have one in progress We close a commit request if there's already one in progress. This patch fixes a problem that may be triggered if two consecutive commit requests are received. Signed-off-by: Pablo Neira Ayuso --- src/cache_iterators.c | 6 ++++++ src/sync-mode.c | 1 + 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/cache_iterators.c b/src/cache_iterators.c index c7183fd..2707366 100644 --- a/src/cache_iterators.c +++ b/src/cache_iterators.c @@ -184,6 +184,11 @@ void cache_commit(struct cache *c, struct nfct_handle *h, int clientfd) }; struct timeval commit_stop, res; + /* we already have one commit in progress, close this request. */ + if (clientfd && STATE_SYNC(commit).clientfd != -1) { + close(clientfd); + return; + } switch(STATE_SYNC(commit).state) { case COMMIT_STATE_INACTIVE: gettimeofday(&STATE_SYNC(commit).stats.start, NULL); @@ -241,6 +246,7 @@ void cache_commit(struct cache *c, struct nfct_handle *h, int clientfd) /* Close the client socket now that we're done. */ close(STATE_SYNC(commit).clientfd); + STATE_SYNC(commit).clientfd = -1; } } diff --git a/src/sync-mode.c b/src/sync-mode.c index 1250a08..4b48449 100644 --- a/src/sync-mode.c +++ b/src/sync-mode.c @@ -346,6 +346,7 @@ static int init_sync(void) STATE(fds)) == -1) { return -1; } + STATE_SYNC(commit).clientfd = -1; init_alarm(&STATE_SYNC(reset_cache_alarm), NULL, do_reset_cache_alarm); -- cgit v1.2.3