summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJones Syue <jonessyue@qnap.com>2023-01-12 15:47:20 +0800
committerVolker Lendecke <vl@samba.org>2023-01-12 11:40:19 +0000
commit98d84192a03a4f1135eaf1590fb62b16d8bc49c8 (patch)
tree12907287f899a50850389e30bb0ef8e17b60aa55 /source3
parentde5d31f452b2445bd92b1746efb05aa096716af8 (diff)
downloadsamba-98d84192a03a4f1135eaf1590fb62b16d8bc49c8.tar.gz
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
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/mdsearch.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source3/utils/mdsearch.c b/source3/utils/mdsearch.c
index ab48e366a0a..eddb83874cb 100644
--- a/source3/utils/mdsearch.c
+++ b/source3/utils/mdsearch.c
@@ -144,12 +144,12 @@ int main(int argc, char **argv)
flags);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("Cannot connect to server: %s\n", nt_errstr(status));
- goto fail;
+ goto fail_free_messaging;
}
status = cli_rpc_pipe_open_noauth(cli, &ndr_table_mdssvc, &rpccli);
if (!NT_STATUS_IS_OK(status)) {
- goto fail;
+ goto fail_free_messaging;
}
status = mdscli_connect(frame,
@@ -159,7 +159,7 @@ int main(int argc, char **argv)
&mdscli_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect mdssvc\n");
- goto fail;
+ goto fail_free_messaging;
}
if (opt_path == NULL) {
@@ -168,7 +168,7 @@ int main(int argc, char **argv)
basepath = talloc_strdup(frame, opt_path);
}
if (basepath == NULL) {
- goto fail;
+ goto fail_free_messaging;
}
status = mdscli_search(frame,
@@ -179,7 +179,7 @@ int main(int argc, char **argv)
&search);
if (!NT_STATUS_IS_OK(status)) {
printf("mdscli_search failed\n");
- goto fail;
+ goto fail_free_messaging;
}
if (!opt_live) {
@@ -199,7 +199,7 @@ int main(int argc, char **argv)
}
if (!NT_STATUS_IS_OK(status)) {
printf("mdscli_get_results failed\n");
- goto fail;
+ goto fail_free_messaging;
}
ncnids = talloc_array_length(cnids);
@@ -217,7 +217,7 @@ int main(int argc, char **argv)
if (!NT_STATUS_IS_OK(status)) {
printf("Get path for CNID 0x%"PRIx64" failed\n",
cnids[i]);
- goto fail;
+ goto fail_free_messaging;
}
printf("%s\n", path);
TALLOC_FREE(path);
@@ -227,13 +227,13 @@ int main(int argc, char **argv)
status = mdscli_close_search(&search);
if (!NT_STATUS_IS_OK(status)) {
printf("mdscli_close_search failed\n");
- goto fail;
+ goto fail_free_messaging;
}
status = mdscli_disconnect(mdscli_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("mdscli_disconnect failed\n");
- goto fail;
+ goto fail_free_messaging;
}
cmdline_messaging_context_free();
@@ -241,6 +241,8 @@ int main(int argc, char **argv)
poptFreeContext(pc);
return 0;
+fail_free_messaging:
+ cmdline_messaging_context_free();
fail:
poptFreeContext(pc);
TALLOC_FREE(frame);