mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
ctdb-common: Remove unused function ctdb_parse_connections()
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
96e3ea5462
commit
cadd0d51fb
@ -62,7 +62,4 @@ void mkdir_p_or_die(const char *dir, int mode);
|
||||
|
||||
void ctdb_wait_for_process_to_exit(pid_t pid);
|
||||
|
||||
int ctdb_parse_connections(FILE *fp, TALLOC_CTX *mem_ctx,
|
||||
int *num_conn, struct ctdb_connection **out);
|
||||
|
||||
#endif /* __CTDB_SYSTEM_H__ */
|
||||
|
@ -378,60 +378,3 @@ void ctdb_wait_for_process_to_exit(pid_t pid)
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
|
||||
int ctdb_parse_connections(FILE *fp, TALLOC_CTX *mem_ctx,
|
||||
int *num_conn, struct ctdb_connection **out)
|
||||
{
|
||||
struct ctdb_connection *conn = NULL;
|
||||
char line[128], src[128], dst[128]; /* long enough for IPv6 */
|
||||
int line_num, ret;
|
||||
int num = 0, max = 0;
|
||||
|
||||
line_num = 0;
|
||||
while (! feof(fp)) {
|
||||
if (fgets(line, sizeof(line), fp) == NULL) {
|
||||
break;
|
||||
}
|
||||
line_num += 1;
|
||||
|
||||
/* Skip empty lines */
|
||||
if (line[0] == '\n') {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = sscanf(line, "%s %s\n", src, dst);
|
||||
if (ret != 2) {
|
||||
DEBUG(DEBUG_ERR, ("Bad line [%d]: %s\n",
|
||||
line_num, line));
|
||||
talloc_free(conn);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (num >= max) {
|
||||
max += 1024;
|
||||
conn = talloc_realloc(mem_ctx, conn,
|
||||
struct ctdb_connection, max);
|
||||
if (conn == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
if (! parse_ip_port(src, &conn[num].src)) {
|
||||
DEBUG(DEBUG_ERR, ("Invalid IP address %s\n", src));
|
||||
talloc_free(conn);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (! parse_ip_port(dst, &conn[num].dst)) {
|
||||
DEBUG(DEBUG_ERR, ("Invalid IP address %s\n", dst));
|
||||
talloc_free(conn);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
num += 1;
|
||||
}
|
||||
|
||||
*num_conn = num;
|
||||
*out = conn;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user