Skip to content

Commit 905c82e

Browse files
committed
Remove the unused __open_inet_server()
1 parent 6c12a04 commit 905c82e

File tree

2 files changed

+3
-94
lines changed

2 files changed

+3
-94
lines changed

main/cnx.c

Lines changed: 3 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -40,43 +40,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4040
static volatile int backlog_unix = 65536;
4141
static volatile int backlog_tcp = 4096;
4242

43-
static int
44-
__addr_split(gchar *url_wrk, gchar ** host, gchar ** port)
45-
{
46-
int len;
47-
gchar *last_semicolon;
48-
49-
len = strlen(url_wrk);
50-
51-
if (*url_wrk == '[') { /*[IP]:PORT */
52-
53-
last_semicolon = g_strrstr(url_wrk, ":");
54-
if (!last_semicolon || last_semicolon - url_wrk >= len)
55-
return 0;
56-
57-
*(last_semicolon - 1) = '\0';
58-
*port = &(last_semicolon[1]);
59-
*host = &(url_wrk[1]);
60-
return 1;
61-
}
62-
63-
last_semicolon = g_strrstr(url_wrk, ":");
64-
if (!last_semicolon || last_semicolon - url_wrk >= len)
65-
return 0;
66-
67-
*last_semicolon = '\0';
68-
*port = &(last_semicolon[1]);
69-
*host = &(url_wrk[0]);
70-
return 1;
71-
}
72-
7343
int
7444
__open_unix_client(const char *path)
7545
{
7646
int sock;
77-
struct sockaddr_un local;
47+
struct sockaddr_un local = {};
7848

79-
memset(&local, 0x00, sizeof(local));
8049
if (!path || strlen(path) >= sizeof(local.sun_path)) {
8150
errno = EINVAL;
8251
return -1;
@@ -116,10 +85,8 @@ __open_unix_client(const char *path)
11685
int
11786
__open_unix_server(const char *path)
11887
{
119-
int sock;
120-
struct sockaddr_un local;
88+
struct sockaddr_un local = {};
12189

122-
memset(&local, 0x00, sizeof(local));
12390
if (!path || strlen(path) >= sizeof(local.sun_path)) {
12491
errno = EINVAL;
12592
return -1;
@@ -132,7 +99,7 @@ __open_unix_server(const char *path)
13299
# define SOCK_FLAGS 0
133100
#endif
134101

135-
sock = socket(PF_UNIX, SOCK_STREAM | SOCK_FLAGS, 0);
102+
int sock = socket(PF_UNIX, SOCK_STREAM | SOCK_FLAGS, 0);
136103
if (sock < 0)
137104
return -1;
138105

@@ -166,59 +133,3 @@ __open_unix_server(const char *path)
166133
return -1;
167134
}
168135

169-
int
170-
__open_inet_server(const char *url)
171-
{
172-
gchar url_wrk[512];
173-
174-
int sock = -1;
175-
int i_opt = 1;
176-
struct sockaddr_in sin;
177-
gchar *host=NULL, *port=NULL;
178-
179-
memset(url_wrk, 0x00, sizeof(url_wrk));
180-
g_strlcpy(url_wrk, url, sizeof(url_wrk)-1);
181-
182-
if (!__addr_split(url_wrk, &host, &port)) {
183-
errno = EINVAL;
184-
return -1;
185-
}
186-
187-
sock = socket(PF_INET, SOCK_STREAM, 0);
188-
if (sock < 0) {
189-
/* transmit the errno as is */
190-
return -1;
191-
}
192-
193-
/* SO_REUSEADDR */
194-
i_opt = 1;
195-
if (0 != setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (void*) &i_opt, sizeof(i_opt)))
196-
WARN("Cannot set SO_REUSEADDR flag on socket %d (%s)", sock, strerror(errno));
197-
198-
/* bind on the given URL then wait for incoming connections */
199-
memset(&sin, 0x00, sizeof(sin));
200-
sin.sin_family = AF_INET;
201-
sin.sin_port = htons(atoi(port));
202-
if (!inet_aton(host, &(sin.sin_addr)))
203-
goto label_error;
204-
205-
if (-1 == bind(sock, (struct sockaddr *)&sin, sizeof(sin)))
206-
goto label_error;
207-
208-
if (-1 == listen(sock, backlog_tcp))
209-
goto label_error;
210-
211-
errno = 0;
212-
return sock;
213-
214-
label_error:
215-
if (sock >= 0) {
216-
typeof(errno) errsav;
217-
errsav = errno;
218-
close(sock);
219-
errno = errsav;
220-
}
221-
return -1;
222-
}
223-
224-

main/gridinit_internals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ int __open_unix_server(const char *path);
8484

8585
int __open_unix_client(const char *path);
8686

87-
int __open_inet_server(const char *url);
88-
8987
/* Groups matching */
9088

9189
gboolean gridinit_group_in_set(const gchar *group, const gchar *set);

0 commit comments

Comments
 (0)