mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
ctdb-daemon: Use ctdb_parse_node_address() in ctdbd
While here, fix a trivial memory leak (ctdbd will exit anyway if this function fails). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Tue Jul 23 12:39:18 UTC 2024 on atb-devel-224
This commit is contained in:
parent
181cc097ef
commit
ead5a3111f
@ -101,9 +101,6 @@ bool ctdb_set_helper(const char *type, char *helper, size_t size,
|
||||
const char *envvar,
|
||||
const char *dir, const char *file);
|
||||
|
||||
int ctdb_parse_address(TALLOC_CTX *mem_ctx, const char *str,
|
||||
ctdb_sock_addr *address);
|
||||
|
||||
bool ctdb_same_address(ctdb_sock_addr *a1, ctdb_sock_addr *a2);
|
||||
|
||||
uint32_t ctdb_hash(const TDB_DATA *key);
|
||||
|
@ -140,36 +140,6 @@ bool ctdb_set_helper(const char *type, char *helper, size_t size,
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
parse a IP:port pair
|
||||
*/
|
||||
int ctdb_parse_address(TALLOC_CTX *mem_ctx, const char *str,
|
||||
ctdb_sock_addr *address)
|
||||
{
|
||||
struct servent *se;
|
||||
int port;
|
||||
int ret;
|
||||
|
||||
setservent(0);
|
||||
se = getservbyname("ctdb", "tcp");
|
||||
endservent();
|
||||
|
||||
if (se == NULL) {
|
||||
port = CTDB_PORT;
|
||||
} else {
|
||||
port = ntohs(se->s_port);
|
||||
}
|
||||
|
||||
ret = ctdb_sock_addr_from_string(str, address, false);
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
ctdb_sock_addr_set_port(address, port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
check if two addresses are the same
|
||||
*/
|
||||
|
@ -154,10 +154,14 @@ fail:
|
||||
*/
|
||||
int ctdb_set_address(struct ctdb_context *ctdb, const char *address)
|
||||
{
|
||||
bool ok;
|
||||
|
||||
ctdb->address = talloc(ctdb, ctdb_sock_addr);
|
||||
CTDB_NO_MEMORY(ctdb, ctdb->address);
|
||||
|
||||
if (ctdb_parse_address(ctdb, address, ctdb->address) != 0) {
|
||||
ok = ctdb_parse_node_address(address, ctdb->address);
|
||||
if (!ok) {
|
||||
TALLOC_FREE(ctdb->address);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user