s3:utils:mdsearch go to cmdline_messaging_context_free
authorJones Syue <jonessyue@qnap.com>
Thu, 12 Jan 2023 07:47:20 +0000 (15:47 +0800)
committerVolker Lendecke <vl@samba.org>
Thu, 12 Jan 2023 11:40:19 +0000 (11:40 +0000)
commit98d84192a03a4f1135eaf1590fb62b16d8bc49c8
tree12907287f899a50850389e30bb0ef8e17b60aa55
parentde5d31f452b2445bd92b1746efb05aa096716af8
s3:utils:mdsearch go to cmdline_messaging_context_free

mdsearch utility would exit earlier with failure in several cases like:
a. samba server is not running yet,
[~] # mdsearch -Uuser%password1 ${server} Public '*=="Samba"'
main: Cannot connect to server: NT_STATUS_CONNECTION_REFUSED

b. spotlight backend service is not ready yet,
[~] # mdsearch -Uuser%password1 ${server} Public '*=="Samba"'
Failed to connect mdssvc

c. mdsearch utility paramters is not as expecred,
[~] # mdsearch -Uuser%password1 ${server} share_not_exist '*=="Samba"'
mdscli_search failed

And in the mean while once mdsearch utility exit earlier with failure,
the lock files are left behind in the directory 'msg.sock' and 'msg.lock'.
If a script to run mdsearch utility in a loop,
this might result in used space slowly growing-up on underlying filesystem.

Supposed to add a new label 'fail_free_messaging',
make it go through the cmdline_messaging_context_free() which deletes the
lock files in the directory msg.sock and msg.lock before mdsearch utility
is exiting with failure.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15284

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jan 12 11:40:19 UTC 2023 on sn-devel-184
source3/utils/mdsearch.c