From d5d01cbf537f3c292477771d0e0ac6a0cbe19994 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 10 May 2014 15:52:00 +0200 Subject: race condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-server/mds-server.c | 46 +++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mds-server/mds-server.c b/src/mds-server/mds-server.c index e63b1af..32cda45 100644 --- a/src/mds-server/mds-server.c +++ b/src/mds-server/mds-server.c @@ -994,27 +994,33 @@ void multicast_message(char* message, size_t length) /* Look for a matching condition. */ n = client->interception_conditions_count; - with_mutex(mutex, - for (i = 0; i < n; i++) - { - interception_condition_t* cond = conds + i; - for (j = 0; j < header_count; j++) - { - if (*(cond->condition) == '\0') - break; - if (cond->header_hash == hashes[j]) - if (strequals(cond->condition, headers[j]) || - strequals(cond->condition, header_values[j])) + errno = 0; + if (client->open) + with_mutex(mutex, + if (errno || (client->open == 0)) + n == 0; + for (i = 0; i < n; i++) + { + interception_condition_t* cond = conds + i; + for (j = 0; j < header_count; j++) + { + if (*(cond->condition) == '\0') break; - } - if (j < header_count) - { - priority = cond->priority; - modifying = cond->modifying; - break; - } - } - ); + if (cond->header_hash == hashes[j]) + if (strequals(cond->condition, headers[j]) || + strequals(cond->condition, header_values[j])) + break; + } + if (j < header_count) + { + priority = cond->priority; + modifying = cond->modifying; + break; + } + } + ); + else + n = 0; /* List client of there was a matching condition. */ if (i < n) -- cgit v1.2.3-70-g09d2