From 56dc3f7dcad22667aa03d3b0794f49378614320a Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Thu, 31 Jul 2014 20:17:24 +0400
Subject: [PATCH] A fix for gh-180: write bind_ipaddr in proctitle and in the
 log.

No test case since we don't test contents of the log in 1.5.
---
 include/evio.h   |  2 ++
 src/evio.cc      | 15 ++++++---------
 src/tarantool.cc |  4 ++++
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/include/evio.h b/include/evio.h
index 5e609e6762..3f3a5e2c21 100644
--- a/include/evio.h
+++ b/include/evio.h
@@ -62,6 +62,8 @@ struct evio_service
 {
 	/** Service name. E.g. 'primary', 'secondary', etc. */
 	char name[SERVICE_NAME_MAXLEN];
+	/** Bind IP address, useful for logging */
+	char host[SERVICE_NAME_MAXLEN];
 
 	/** Interface/port to bind to */
 	struct sockaddr_in addr;
diff --git a/src/evio.cc b/src/evio.cc
index 23af2a45aa..de66eb1dcb 100644
--- a/src/evio.cc
+++ b/src/evio.cc
@@ -173,12 +173,6 @@ evio_service_port(struct evio_service *service)
 	return ntohs(service->addr.sin_port);
 }
 
-static inline const char *
-evio_service_name(struct evio_service *service)
-{
-	return service->name;
-}
-
 /**
  * A callback invoked by libev when acceptor socket is ready.
  * Accept the socket, initialize it and pass to the on_accept
@@ -234,8 +228,10 @@ evio_service_bind_and_listen(struct evio_service *service)
 			close(fd);
 			return -1;
 		}
-		say_info("bound to %s port %i", evio_service_name(service),
-			 evio_service_port(service));
+		say_info("bound to %s port %i, ip %s",
+			 service->name,
+			 evio_service_port(service),
+			 service->host);
 
 		/* Invoke on_bind callback if it is set. */
 		if (service->on_bind)
@@ -275,6 +271,7 @@ evio_service_init(struct evio_service *service, const char *name,
 {
 	memset(service, 0, sizeof(struct evio_service));
 	snprintf(service->name, sizeof(service->name), "%s", name);
+	snprintf(service->host, sizeof(service->host), "%s", host);
 
 	service->addr.sin_family = AF_INET;
 	service->addr.sin_port = htons(port);
@@ -309,7 +306,7 @@ evio_service_start(struct evio_service *service)
 		/* Try again after a delay. */
 		say_warn("%s port %i is already in use, will "
 			 "retry binding after %lf seconds.",
-			 evio_service_name(service),
+			 service->name,
 			 evio_service_port(service), BIND_RETRY_DELAY);
 
 		ev_timer_set(&service->timer,
diff --git a/src/tarantool.cc b/src/tarantool.cc
index d29fb188f8..28393050b2 100644
--- a/src/tarantool.cc
+++ b/src/tarantool.cc
@@ -142,6 +142,10 @@ title(const char *role, const char *fmt, ...)
 		if (*pptr)
 			bufptr += snprintf(bufptr, bufend - bufptr,
 					   " %s: %i", *nptr, *pptr);
+	if (strlen(cfg.bind_ipaddr)) {
+		bufptr += snprintf(bufptr, bufend - bufptr,
+				   ", ip: %s", cfg.bind_ipaddr);
+	}
 
 	set_proc_title(buf);
 }
-- 
GitLab