From 8a0fae8d913239b99fcc8403c53b393b4d3e7997 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Nov 2014 15:10:56 -0800 Subject: [PATCH] s3: leases : If we are requested to send a break message from another smbd, ensure we're in sync with the current lease state. If a lease is shared between two smbd processes the state can get out of sync. Signed-off-by: Jeremy Allison --- source3/smbd/oplock.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index e97ade6..d28914c 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -598,9 +598,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, return; } - if ((fsp->oplock_type == LEASE_OPLOCK) && - (fsp->lease->lease.lease_version != 1)) { - /* Need to increment the epoch */ + if (fsp->oplock_type == LEASE_OPLOCK) { struct share_mode_lock *lck; int idx; @@ -615,8 +613,13 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, if (idx != -1) { struct share_mode_oplock *o; o = &lck->data->leases[idx]; - o->epoch += 1; - fsp->lease->lease.lease_epoch = o->epoch; + /* Ensure we're in sync with current lease state. */ + fsp->lease->lease.lease_state = o->current_state; + if (fsp->lease->lease.lease_version != 1) { + /* Need to increment the epoch */ + o->epoch += 1; + fsp->lease->lease.lease_epoch = o->epoch; + } } TALLOC_FREE(lck); -- 2.1.0.rc2.206.gedb03e5