Skip to content

Commit 4944b3d

Browse files
committed
Turn static __open_unix_server(), used only once
1 parent c006e84 commit 4944b3d

File tree

3 files changed

+51
-57
lines changed

3 files changed

+51
-57
lines changed

main/cnx.c

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2424
#include <fcntl.h>
2525
#include <string.h>
2626
#include <strings.h>
27-
#include <arpa/inet.h>
28-
#include <netinet/in.h>
29-
#include <netinet/tcp.h>
3027
#include <sys/socket.h>
3128
#include <sys/types.h>
3229
#include <sys/stat.h>
3330
#include <sys/un.h>
3431

3532
#include <glib.h>
3633

37-
#include "gridinit-utils.h"
3834
#include "gridinit_internals.h"
3935

4036
int
@@ -73,54 +69,3 @@ __open_unix_client(const char *path)
7369
return -1;
7470
}
7571

76-
int
77-
__open_unix_server(const char *path)
78-
{
79-
struct sockaddr_un local = {};
80-
81-
if (!path || strlen(path) >= sizeof(local.sun_path)) {
82-
errno = EINVAL;
83-
return -1;
84-
}
85-
86-
/* Create ressources to monitor */
87-
#ifdef SOCK_CLOEXEC
88-
# define SOCK_FLAGS SOCK_CLOEXEC
89-
#else
90-
# define SOCK_FLAGS 0
91-
#endif
92-
93-
int sock = socket(PF_UNIX, SOCK_STREAM | SOCK_FLAGS, 0);
94-
if (sock < 0)
95-
return -1;
96-
97-
#ifndef SOCK_CLOEXEC
98-
# ifdef FD_CLOEXEC
99-
(void) fcntl(sock, F_SETFD, fcntl(sock, F_GETFD)|FD_CLOEXEC);
100-
# endif
101-
#endif
102-
103-
/* Bind to file */
104-
local.sun_family = AF_UNIX;
105-
g_strlcpy(local.sun_path, path, sizeof(local.sun_path)-1);
106-
107-
if (-1 == bind(sock, (struct sockaddr *)&local, sizeof(local)))
108-
goto label_error;
109-
110-
/* Listen on that socket */
111-
if (-1 == listen(sock, 65536))
112-
goto label_error;
113-
114-
errno = 0;
115-
return sock;
116-
117-
label_error:
118-
if (sock >= 0) {
119-
typeof(errno) errsav;
120-
errsav = errno;
121-
close(sock);
122-
errno = errsav;
123-
}
124-
return -1;
125-
}
126-

main/gridinit.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,57 @@ servers_save_fd(int fd, const char *url)
848848
return TRUE;
849849
}
850850

851+
static int
852+
__open_unix_server(const char *path)
853+
{
854+
struct sockaddr_un local = {};
855+
856+
if (!path || strlen(path) >= sizeof(local.sun_path)) {
857+
errno = EINVAL;
858+
return -1;
859+
}
860+
861+
/* Create ressources to monitor */
862+
#ifdef SOCK_CLOEXEC
863+
# define SOCK_FLAGS SOCK_CLOEXEC
864+
#else
865+
# define SOCK_FLAGS 0
866+
#endif
867+
868+
int sock = socket(PF_UNIX, SOCK_STREAM | SOCK_FLAGS, 0);
869+
if (sock < 0)
870+
return -1;
871+
872+
#ifndef SOCK_CLOEXEC
873+
# ifdef FD_CLOEXEC
874+
(void) fcntl(sock, F_SETFD, fcntl(sock, F_GETFD)|FD_CLOEXEC);
875+
# endif
876+
#endif
877+
878+
/* Bind to file */
879+
local.sun_family = AF_UNIX;
880+
g_strlcpy(local.sun_path, path, sizeof(local.sun_path)-1);
881+
882+
if (-1 == bind(sock, (struct sockaddr *)&local, sizeof(local)))
883+
goto label_error;
884+
885+
/* Listen on that socket */
886+
if (-1 == listen(sock, 65536))
887+
goto label_error;
888+
889+
errno = 0;
890+
return sock;
891+
892+
label_error:
893+
if (sock >= 0) {
894+
typeof(errno) errsav;
895+
errsav = errno;
896+
close(sock);
897+
errno = errsav;
898+
}
899+
return -1;
900+
}
901+
851902
/**
852903
* Opens a UNIX server socket then manage a server based on it
853904
*/

main/gridinit_internals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
8080
# define CFG_KEY_INHERIT "inherit_env"
8181
#endif
8282

83-
int __open_unix_server(const char *path);
84-
8583
int __open_unix_client(const char *path);
8684

8785
/* Groups matching */

0 commit comments

Comments
 (0)