summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJeffrey Hutzelman <jhutz@cmu.edu>2013-01-08 10:16:07 -0500
committerRuss Allbery <rra@stanford.edu>2013-02-22 16:48:00 -0800
commitdc825b8b49ab6cc6af4074faa559f5656c719921 (patch)
tree9f8cc87aad1d276fe06e26f8ab15d062769e85f3 /client
parent02fd6118ab67a7ad6c2620a4e3ecee0f8341ffa2 (diff)
Abstract out connection reset before open
remctl_open() performs certain operations to "reset" a connection before opening it. These have now been abstracted out into a new internal_reset() in order to allow them to be shared between multiple open interfaces. Change-Id: Ie309f288dd2e52d82e71bcb2e9dc74320515dab5 Reviewed-on: https://gerrit.stanford.edu/807 Reviewed-by: Russ Allbery <rra@stanford.edu> Tested-by: Russ Allbery <rra@stanford.edu>
Diffstat (limited to 'client')
-rw-r--r--client/api.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/client/api.c b/client/api.c
index 2e6ecb1..c9c17da 100644
--- a/client/api.c
+++ b/client/api.c
@@ -305,17 +305,9 @@ remctl_set_timeout(struct remctl *r, time_t timeout)
}
-/*
- * Open a new persistant remctl connection to a server, given the host, port,
- * and principal. Returns true on success and false on failure.
- */
-int
-remctl_open(struct remctl *r, const char *host, unsigned short port,
- const char *principal)
+static void
+internal_reset(struct remctl *r)
{
- bool port_fallback = false;
- socket_type fd = INVALID_SOCKET;
-
if (r->fd != -1) {
if (r->protocol > 1)
internal_v2_quit(r);
@@ -330,6 +322,21 @@ remctl_open(struct remctl *r, const char *host, unsigned short port,
free(r->output);
r->output = NULL;
}
+}
+
+
+/*
+ * Open a new persistant remctl connection to a server, given the host, port,
+ * and principal. Returns true on success and false on failure.
+ */
+int
+remctl_open(struct remctl *r, const char *host, unsigned short port,
+ const char *principal)
+{
+ bool port_fallback = false;
+ socket_type fd = INVALID_SOCKET;
+
+ internal_reset(r);
r->host = host;
r->port = port;
r->principal = principal;