From e7b5a3a7eb78a6d79572b2362707c5bbe9c32aa4 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Thu, 11 Jun 2009 17:18:04 +0200 Subject: fixed socket creation --- lib/CommLayer/CommLayerServerSocket.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/CommLayer/CommLayerServerSocket.cpp b/lib/CommLayer/CommLayerServerSocket.cpp index 12db88c9..38571942 100644 --- a/lib/CommLayer/CommLayerServerSocket.cpp +++ b/lib/CommLayer/CommLayerServerSocket.cpp @@ -170,13 +170,14 @@ CCommLayerServerSocket::CCommLayerServerSocket() int len; struct sockaddr_un local; + unlink(SOCKET_PATH); if ((m_nSocket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { throw CABRTException(EXCEP_FATAL, "CCommLayerServerSocket::CCommLayerServerSocket(): Can not create socket."); } + fcntl(m_nSocket, F_SETFD, FD_CLOEXEC); local.sun_family = AF_UNIX; strcpy(local.sun_path, SOCKET_PATH); - unlink(local.sun_path); len = strlen(local.sun_path) + sizeof(local.sun_family); if (bind(m_nSocket, (struct sockaddr *)&local, len) == -1) { @@ -186,9 +187,7 @@ CCommLayerServerSocket::CCommLayerServerSocket() { throw CABRTException(EXCEP_FATAL, "CCommLayerServerSocket::CCommLayerServerSocket(): Can not listen on the socket."); } - - fcntl(m_nSocket, F_SETFD, FD_CLOEXEC); - fchmod(m_nSocket, SOCKET_PERMISSION); + chmod(SOCKET_PATH, SOCKET_PERMISSION); m_pGSocket = g_io_channel_unix_new(m_nSocket); if (!g_io_add_watch(m_pGSocket, -- cgit