summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-05-14 01:04:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:22 -0500
commitaf0ba915f5b8b756747b095680af7aff510b5bf5 (patch)
tree9b35f1e7ae68af7cf22d26acd7a234f92d788472 /source4
parentbb2571cb9071ff0367122e651d96cb2d39494257 (diff)
downloadsamba-af0ba915f5b8b756747b095680af7aff510b5bf5.tar.gz
samba-af0ba915f5b8b756747b095680af7aff510b5bf5.tar.bz2
samba-af0ba915f5b8b756747b095680af7aff510b5bf5.zip
r22834: fixed a memory leak in the torture_open_connection() code, and removed
the duplicate handling of the unclist. This now exposes a function torture_get_conn_index() which can be used by tests to work out which host to talk to using the unclist. I will be using that as part of a set of tests for clustered Samba that need to do auto-reconnect (to allow testing of cluster node failure) (This used to be commit b505c176a8d90e406fbf9a94840267d1d9dc34c6)
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/util_smb.c79
1 files changed, 37 insertions, 42 deletions
diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c
index 75fa9648f4..c47741c5b9 100644
--- a/source4/torture/util_smb.c
+++ b/source4/torture/util_smb.c
@@ -486,67 +486,62 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
return True;
}
-_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, int conn_index)
+_PUBLIC_ bool torture_get_conn_index(int conn_index,
+ TALLOC_CTX *mem_ctx,
+ char **host, char **share)
{
- const char *host = lp_parm_string(-1, "torture", "host");
- const char *share = lp_parm_string(-1, "torture", "share");
char **unc_list = NULL;
int num_unc_names = 0;
const char *p;
+
+ (*host) = talloc_strdup(mem_ctx, lp_parm_string(-1, "torture", "host"));
+ (*share) = talloc_strdup(mem_ctx, lp_parm_string(-1, "torture", "share"));
p = lp_parm_string(-1, "torture", "unclist");
- if (p) {
- char *h, *s;
- unc_list = file_lines_load(p, &num_unc_names, NULL);
- if (!unc_list || num_unc_names <= 0) {
- printf("Failed to load unc names list from '%s'\n", p);
- exit(1);
- }
+ if (!p) {
+ return True;
+ }
- if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names],
- NULL, &h, &s)) {
- printf("Failed to parse UNC name %s\n",
- unc_list[conn_index % num_unc_names]);
- exit(1);
- }
- host = h;
- share = s;
+ unc_list = file_lines_load(p, &num_unc_names, NULL);
+ if (!unc_list || num_unc_names <= 0) {
+ DEBUG(0,("Failed to load unc names list from '%s'\n", p));
+ return False;
}
- return torture_open_connection_share(NULL, c, host, share, NULL);
+ if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names],
+ mem_ctx, host, share)) {
+ DEBUG(0, ("Failed to parse UNC name %s\n",
+ unc_list[conn_index % num_unc_names]));
+ return False;
+ }
+
+ talloc_free(unc_list);
+ return True;
}
+
+
_PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
int conn_index,
struct event_context *ev)
{
- const char *host = lp_parm_string(-1, "torture", "host");
- const char *share = lp_parm_string(-1, "torture", "share");
- char **unc_list = NULL;
- int num_unc_names = 0;
- const char *p;
-
- p = lp_parm_string(-1, "torture", "unclist");
- if (p) {
- char *h, *s;
- unc_list = file_lines_load(p, &num_unc_names, NULL);
- if (!unc_list || num_unc_names <= 0) {
- printf("Failed to load unc names list from '%s'\n", p);
- exit(1);
- }
+ char *host, *share;
+ bool ret;
- if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names],
- NULL, &h, &s)) {
- printf("Failed to parse UNC name %s\n",
- unc_list[conn_index % num_unc_names]);
- exit(1);
- }
- host = h;
- share = s;
+ if (!torture_get_conn_index(conn_index, ev, &host, &share)) {
+ return False;
}
+ ret = torture_open_connection_share(NULL, c, host, share, ev);
+ talloc_free(host);
+ talloc_free(share);
+
+ return ret;
+}
- return torture_open_connection_share(NULL, c, host, share, ev);
+_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, int conn_index)
+{
+ return torture_open_connection_ev(c, conn_index, NULL);
}