From c7341b2e92be39bf5b8af5784c39842cac56d59f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Jan 2005 10:57:43 +1100 Subject: [PATCH] Incorporate Jonas Orland's suggestions. ndb/src/common/util/SocketServer.cpp: Check for errors from getsockname (and error display). use SOCKET_SIZE_TYPE (as discovered by configure) instead of socklen_t --- ndb/src/common/util/SocketServer.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ndb/src/common/util/SocketServer.cpp b/ndb/src/common/util/SocketServer.cpp index d2caf9c920c..f50ed4eb1ed 100644 --- a/ndb/src/common/util/SocketServer.cpp +++ b/ndb/src/common/util/SocketServer.cpp @@ -119,8 +119,19 @@ SocketServer::setup(SocketServer::Service * service, NDB_CLOSE_SOCKET(sock); DBUG_RETURN(false); } - socklen_t sock_len = sizeof(servaddr); - getsockname(sock,(struct sockaddr*)&servaddr,&sock_len); + + /* Get the port we bound to */ + SOCKET_SIZE_TYPE sock_len = sizeof(servaddr); + if(getsockname(sock,(struct sockaddr*)&servaddr,&sock_len)<0) { + char msg[100]; + if(!strerror_r(errno,msg,sizeof(msg))) + strcpy(msg,"Unknown"); + ndbout_c("An error occurred while trying to find out what" + " port we bound to. Error: %s",msg); + NDB_CLOSE_SOCKET(sock); + DBUG_RETURN(false); + } + DBUG_PRINT("info",("bound to %u",ntohs(servaddr.sin_port))); if (listen(sock, m_maxSessions) == -1){ DBUG_PRINT("error",("listen() - %d - %s",