Commit c99f522f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Retire VSS_open

parent 01001b90
......@@ -37,4 +37,3 @@ int VSS_resolver(const char *addr, const char *def_port, vss_resolved_f *func,
int VSS_resolve(const char *addr, const char *port, struct vss_addr ***ta);
int VSS_bind(const struct vss_addr *addr);
int VSS_listen(const struct vss_addr *addr, int depth);
int VSS_open(const char *str, double tmo);
......@@ -288,61 +288,3 @@ VSS_listen(const struct vss_addr *va, int depth)
}
return (sd);
}
/*
* Connect to the socket specified by the address info in va.
* Return the socket.
*/
static int
vss_connect(const struct vss_addr *va, int nonblock)
{
int sd, i;
sd = socket(va->va_family, va->va_socktype, va->va_protocol);
if (sd < 0) {
if (errno != EPROTONOSUPPORT)
perror("socket()");
return (-1);
}
if (nonblock)
(void)VTCP_nonblocking(sd);
i = connect(sd, (const void *)&va->va_addr, va->va_addrlen);
if (i == 0 || (nonblock && errno == EINPROGRESS))
return (sd);
perror("connect()");
(void)close(sd);
return (-1);
}
/*
* And the totally brutal version: Give me connection to this address
*/
int
VSS_open(const char *str, double tmo)
{
int retval = -1;
int nvaddr, n, i;
struct vss_addr **vaddr;
struct pollfd pfd;
nvaddr = VSS_resolve(str, NULL, &vaddr);
for (n = 0; n < nvaddr; n++) {
retval = vss_connect(vaddr[n], tmo != 0.0);
if (retval >= 0 && tmo != 0.0) {
pfd.fd = retval;
pfd.events = POLLOUT;
i = poll(&pfd, 1, tmo * 1e3);
if (i == 0 || pfd.revents != POLLOUT) {
(void)close(retval);
retval = -1;
}
}
if (retval >= 0)
break;
}
for (n = 0; n < nvaddr; n++)
free(vaddr[n]);
free(vaddr);
return (retval);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment