gfapi: transport and port are optional for glfs_set_volfile_server
Only server is the required argument for glfs_set_volfile_server and both transport and port are optional. When glfs_set_volfile_server is invocated multiple times, only on the first invocation we replace port 0 with 24007 and transport NULL with "tcp". Hence, replacing the parameters at the entry function is the right way. Change-Id: If9f4a5f7fd9038eed140e2f47167a8fd11acc2f6 BUG: 1260561 Signed-off-by: Raghavendra Talur <rtalur@redhat.com> Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> Reviewed-on: http://review.gluster.org/12114 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
parent
ecfa2edd78
commit
007bfd9632
@ -351,9 +351,12 @@ pub_glfs_unset_volfile_server (struct glfs *fs, const char *transport,
|
|||||||
{
|
{
|
||||||
cmd_args_t *cmd_args = NULL;
|
cmd_args_t *cmd_args = NULL;
|
||||||
server_cmdline_t *server = NULL;
|
server_cmdline_t *server = NULL;
|
||||||
|
server_cmdline_t *tmp = NULL;
|
||||||
|
char *transport_val = NULL;
|
||||||
|
int port_val = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!transport || !host || !port) {
|
if (!fs || !host) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -362,10 +365,30 @@ pub_glfs_unset_volfile_server (struct glfs *fs, const char *transport,
|
|||||||
__GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs);
|
__GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs);
|
||||||
|
|
||||||
cmd_args = &fs->ctx->cmd_args;
|
cmd_args = &fs->ctx->cmd_args;
|
||||||
list_for_each_entry(server, &cmd_args->curr_server->list, list) {
|
|
||||||
|
if (transport) {
|
||||||
|
transport_val = gf_strdup (transport);
|
||||||
|
} else {
|
||||||
|
transport_val = gf_strdup (GF_DEFAULT_VOLFILE_TRANSPORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!transport_val) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port) {
|
||||||
|
port_val = port;
|
||||||
|
} else {
|
||||||
|
port_val = GF_DEFAULT_BASE_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
list_for_each_entry_safe (server, tmp,
|
||||||
|
&cmd_args->curr_server->list,
|
||||||
|
list) {
|
||||||
if ((!strcmp(server->volfile_server, host) &&
|
if ((!strcmp(server->volfile_server, host) &&
|
||||||
!strcmp(server->transport, transport) &&
|
!strcmp(server->transport, transport_val) &&
|
||||||
(server->port == port))) {
|
(server->port == port_val))) {
|
||||||
list_del (&server->list);
|
list_del (&server->list);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto out;
|
goto out;
|
||||||
@ -373,6 +396,7 @@ pub_glfs_unset_volfile_server (struct glfs *fs, const char *transport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
GF_FREE (transport_val);
|
||||||
__GLFS_EXIT_FS;
|
__GLFS_EXIT_FS;
|
||||||
|
|
||||||
invalid_fs:
|
invalid_fs:
|
||||||
@ -421,13 +445,20 @@ pub_glfs_set_volfile_server (struct glfs *fs, const char *transport,
|
|||||||
|
|
||||||
if (transport) {
|
if (transport) {
|
||||||
server->transport = gf_strdup (transport);
|
server->transport = gf_strdup (transport);
|
||||||
if (!server->transport) {
|
} else {
|
||||||
errno = ENOMEM;
|
server->transport = gf_strdup (GF_DEFAULT_VOLFILE_TRANSPORT);
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server->port = port;
|
if (!server->transport) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port) {
|
||||||
|
server->port = port;
|
||||||
|
} else {
|
||||||
|
server->port = GF_DEFAULT_BASE_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
if (!cmd_args->volfile_server) {
|
if (!cmd_args->volfile_server) {
|
||||||
cmd_args->volfile_server = server->volfile_server;
|
cmd_args->volfile_server = server->volfile_server;
|
||||||
@ -437,9 +468,9 @@ pub_glfs_set_volfile_server (struct glfs *fs, const char *transport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry(tmp, &cmd_args->volfile_servers, list) {
|
list_for_each_entry(tmp, &cmd_args->volfile_servers, list) {
|
||||||
if ((!strcmp(tmp->volfile_server, host) &&
|
if ((!strcmp(tmp->volfile_server, server->volfile_server) &&
|
||||||
!strcmp(tmp->transport, transport) &&
|
!strcmp(tmp->transport, server->transport) &&
|
||||||
(tmp->port == port))) {
|
(tmp->port == server->port))) {
|
||||||
errno = EEXIST;
|
errno = EEXIST;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#define _GLOBALS_H
|
#define _GLOBALS_H
|
||||||
|
|
||||||
#define GF_DEFAULT_BASE_PORT 24007
|
#define GF_DEFAULT_BASE_PORT 24007
|
||||||
|
#define GF_DEFAULT_VOLFILE_TRANSPORT "tcp"
|
||||||
|
|
||||||
#define GD_OP_VERSION_KEY "operating-version"
|
#define GD_OP_VERSION_KEY "operating-version"
|
||||||
#define GD_MIN_OP_VERSION_KEY "minimum-operating-version"
|
#define GD_MIN_OP_VERSION_KEY "minimum-operating-version"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user