File tree Expand file tree Collapse file tree 3 files changed +51
-57
lines changed Expand file tree Collapse file tree 3 files changed +51
-57
lines changed Original file line number Diff line number Diff line change @@ -24,17 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24
24
#include <fcntl.h>
25
25
#include <string.h>
26
26
#include <strings.h>
27
- #include <arpa/inet.h>
28
- #include <netinet/in.h>
29
- #include <netinet/tcp.h>
30
27
#include <sys/socket.h>
31
28
#include <sys/types.h>
32
29
#include <sys/stat.h>
33
30
#include <sys/un.h>
34
31
35
32
#include <glib.h>
36
33
37
- #include "gridinit-utils.h"
38
34
#include "gridinit_internals.h"
39
35
40
36
int
@@ -73,54 +69,3 @@ __open_unix_client(const char *path)
73
69
return -1 ;
74
70
}
75
71
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
-
Original file line number Diff line number Diff line change @@ -848,6 +848,57 @@ servers_save_fd(int fd, const char *url)
848
848
return TRUE;
849
849
}
850
850
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
+
851
902
/**
852
903
* Opens a UNIX server socket then manage a server based on it
853
904
*/
Original file line number Diff line number Diff line change @@ -80,8 +80,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
80
80
# define CFG_KEY_INHERIT "inherit_env"
81
81
#endif
82
82
83
- int __open_unix_server (const char * path );
84
-
85
83
int __open_unix_client (const char * path );
86
84
87
85
/* Groups matching */
You can’t perform that action at this time.
0 commit comments