File 0001-lldpad-print-verbose-error-messages.patch of Package open-lldp.21481

From 76abae2f76ae02cd0af19bd7ff4d52e2f9c46bf4 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Wed, 14 May 2014 09:03:43 +0200
Subject: lldpad: print verbose error messages

When lldpad is started while another instance is running it'll
abort with the cryptic error message
'bind(AF_LOCAL): address in use'
This patch updates the error message with the more instructive
'another lldpad instance is running'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 ctrl_iface.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ctrl_iface.c b/ctrl_iface.c
index fbacfac..e4fd0b7 100644
--- a/ctrl_iface.c
+++ b/ctrl_iface.c
@@ -466,7 +466,7 @@ int ctrl_iface_init(struct clif_data *clifd)
 	}
 	s = socket(AF_LOCAL, SOCK_DGRAM, 0);
 	if (s < 0) {
-		perror("socket(AF_LOCAL)");
+		LLDPAD_WARN("failed to create CLI socket: %m\n");
 		goto fail;
 	}
 	/* enable receiving of the sender credentials */
@@ -479,7 +479,10 @@ int ctrl_iface_init(struct clif_data *clifd)
 		 "%s", LLDP_CLIF_SOCK);
 	addrlen = sizeof(sa_family_t) + strlen(addr.sun_path + 1) + 1;
 	if (bind(s, (struct sockaddr *) &addr, addrlen) < 0) {
-		perror("bind(AF_LOCAL)");
+		if (errno == EADDRINUSE)
+			LLDPAD_WARN("another lldpad instance is running\n");
+		else
+			LLDPAD_WARN("failed to bind CLI socket address: %m");
 		goto fail;
 	}
 	/* enable receiving of the sender credentials */
-- 
1.8.5.2

openSUSE Build Service is sponsored by