From 4a0488a16be1c6aa0e8552b35a91094c36e84f20 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 22 Oct 2013 09:00:55 +0200 Subject: [PATCH] socket frontend: Improved error reporting. --- src/frontend/sock.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/frontend/sock.c b/src/frontend/sock.c index 063b2ca..e2c52ce 100644 --- a/src/frontend/sock.c +++ b/src/frontend/sock.c @@ -90,8 +90,8 @@ open_unix_sock(listener_t *listener) listener->sock_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (listener->sock_fd < 0) { char buf[1024]; - sdb_log(SDB_LOG_ERR, "sock: Failed to open UNIX socket: %s", - sdb_strerror(errno, buf, sizeof(buf))); + sdb_log(SDB_LOG_ERR, "sock: Failed to open UNIX socket %s: %s", + listener->address, sdb_strerror(errno, buf, sizeof(buf))); return -1; } @@ -103,8 +103,8 @@ open_unix_sock(listener_t *listener) status = bind(listener->sock_fd, (struct sockaddr *)&sa, sizeof(sa)); if (status) { char buf[1024]; - sdb_log(SDB_LOG_ERR, "sock: Failed to bind to UNIX socket: %s", - sdb_strerror(errno, buf, sizeof(buf))); + sdb_log(SDB_LOG_ERR, "sock: Failed to bind to UNIX socket %s: %s", + listener->address, sdb_strerror(errno, buf, sizeof(buf))); return -1; } return 0; @@ -172,25 +172,37 @@ listener_create(sdb_fe_socket_t *sock, const char *address) int type; type = get_type(address); - if (type < 0) + if (type < 0) { + sdb_log(SDB_LOG_ERR, "sock: Unsupported address type specified " + "in listen address '%s'", address); return NULL; + } listener = realloc(sock->listeners, sock->listeners_num * sizeof(*sock->listeners)); - if (! listener) + if (! listener) { + char buf[1024]; + sdb_log(SDB_LOG_ERR, "sock: Failed to allocate memory: %s", + sdb_strerror(errno, buf, sizeof(buf))); return NULL; + } + sock->listeners = listener; listener = sock->listeners + sock->listeners_num; listener->sock_fd = -1; listener->address = strdup(address); if (! listener->address) { + char buf[1024]; + sdb_log(SDB_LOG_ERR, "sock: Failed to allocate memory: %s", + sdb_strerror(errno, buf, sizeof(buf))); listener_destroy(listener); return NULL; } listener->type = type; if (listener_impls[type].opener(listener)) { + /* prints error */ listener_destroy(listener); return NULL; } -- 2.30.2