summaryrefslogtreecommitdiff
path: root/qcom
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2020-03-01 18:02:13 -0800
committerTodd Kjos <tkjos@google.com>2020-04-25 15:23:59 +0000
commitbf70b7d649e7d705042b007dfc22fc788fc2f1d4 (patch)
treea932ad634be08e2820a684b68e99beeca86aba14 /qcom
parent537853d9360cba5ca812c3047f12f953c9fd4942 (diff)
qcom: qrtr: ns: Go dormant when exsting name server is found
With the introduction of the in-kernel nameserver launching the user space qrtr-ns will fail, but typically other services depends on its presence. As such, go dormant instead of failing when noticed that the name service is already present. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Change-Id: I62aa002294e6980bab0b5e1b7282212b8d2c3d57
Diffstat (limited to 'qcom')
-rw-r--r--qcom/qrtr/src/ns.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/qcom/qrtr/src/ns.c b/qcom/qrtr/src/ns.c
index 4b88a9c..393cc68 100644
--- a/qcom/qrtr/src/ns.c
+++ b/qcom/qrtr/src/ns.c
@@ -685,6 +685,14 @@ static void node_mi_free(struct map_item *mi)
free(node);
}
+static void go_dormant(int sock)
+{
+ close(sock);
+
+ for (;;)
+ sleep(UINT_MAX);
+}
+
static void usage(const char *progname)
{
fprintf(stderr, "%s [-f] [-s] [<node-id>]\n", progname);
@@ -760,8 +768,14 @@ int main(int argc, char **argv)
ctx.local_node = sq.sq_node;
rc = bind(ctx.sock, (void *)&sq, sizeof(sq));
- if (rc < 0)
+ if (rc < 0) {
+ if (errno == EADDRINUSE) {
+ PLOGE("nameserver already running, going dormant");
+ go_dormant(ctx.sock);
+ }
+
PLOGE_AND_EXIT("bind control socket");
+ }
ctx.bcast_sq.sq_family = AF_QIPCRTR;
ctx.bcast_sq.sq_node = QRTR_NODE_BCAST;