smbd: Don't always walk the share mode array in open_mode_check()
authorVolker Lendecke <vl@samba.org>
Mon, 16 Sep 2019 23:16:40 +0000 (16:16 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 18 Sep 2019 00:07:13 +0000 (00:07 +0000)
commitfd61e550acec6e9924a71712eef739b58c7d68e8
treee9094f91077c37826aa744e836bca8ef732ed65f
parentac85ec5ed855d8d0bc2564cbd33a580a8db6818e
smbd: Don't always walk the share mode array in open_mode_check()

share_mode_data->flags contains the "most restrictive" share mode of
the whole array. This is maintained lazily: Whenever set_share_mode()
is called, d->flags is updated if the new share mode got more
restrictive. It is not updated when a file is closed, as this would
mean we would have to walk the whole array, making sure that the
closed handle was indeed the only most restrictive one. Instead, we
walk the share mode array only when a conflict happens: Then we need
to know "the truth" and recalculate it by walking the share mode
array.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Sep 18 00:07:13 UTC 2019 on sn-devel-184
source3/smbd/open.c