|
|
@ -1460,6 +1460,7 @@ void *connector(void *arg) |
|
|
|
proc_instance_t *pi = (proc_instance_t *)arg; |
|
|
|
proc_instance_t *pi = (proc_instance_t *)arg; |
|
|
|
cdata_t *cdata = ckzalloc(sizeof(cdata_t)); |
|
|
|
cdata_t *cdata = ckzalloc(sizeof(cdata_t)); |
|
|
|
int threads, sockd, ret = 0, i, tries = 0; |
|
|
|
int threads, sockd, ret = 0, i, tries = 0; |
|
|
|
|
|
|
|
char newurl[INET6_ADDRSTRLEN], newport[8]; |
|
|
|
ckpool_t *ckp = pi->ckp; |
|
|
|
ckpool_t *ckp = pi->ckp; |
|
|
|
const int on = 1; |
|
|
|
const int on = 1; |
|
|
|
|
|
|
|
|
|
|
@ -1468,16 +1469,13 @@ void *connector(void *arg) |
|
|
|
ckp->cdata = cdata; |
|
|
|
ckp->cdata = cdata; |
|
|
|
cdata->ckp = ckp; |
|
|
|
cdata->ckp = ckp; |
|
|
|
|
|
|
|
|
|
|
|
if (!ckp->serverurls) |
|
|
|
|
|
|
|
cdata->serverfd = ckalloc(sizeof(int *)); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
cdata->serverfd = ckalloc(sizeof(int *) * ckp->serverurls); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!ckp->serverurls) { |
|
|
|
if (!ckp->serverurls) { |
|
|
|
/* No serverurls have been specified. Bind to all interfaces
|
|
|
|
/* No serverurls have been specified. Bind to all interfaces
|
|
|
|
* on default sockets. */ |
|
|
|
* on default sockets. */ |
|
|
|
struct sockaddr_in serv_addr; |
|
|
|
struct sockaddr_in serv_addr; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cdata->serverfd = ckalloc(sizeof(int *)); |
|
|
|
|
|
|
|
|
|
|
|
sockd = socket(AF_INET, SOCK_STREAM, 0); |
|
|
|
sockd = socket(AF_INET, SOCK_STREAM, 0); |
|
|
|
if (sockd < 0) { |
|
|
|
if (sockd < 0) { |
|
|
|
LOGERR("Connector failed to open socket"); |
|
|
|
LOGERR("Connector failed to open socket"); |
|
|
@ -1509,11 +1507,14 @@ void *connector(void *arg) |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
cdata->serverfd[0] = sockd; |
|
|
|
cdata->serverfd[0] = sockd; |
|
|
|
|
|
|
|
url_from_socket(sockd, newurl, newport); |
|
|
|
|
|
|
|
ASPRINTF(&ckp->serverurl[0], "%s:%s", newurl, newport); |
|
|
|
ckp->serverurls = 1; |
|
|
|
ckp->serverurls = 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
cdata->serverfd = ckalloc(sizeof(int *) * ckp->serverurls); |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ckp->serverurls; i++) { |
|
|
|
for (i = 0; i < ckp->serverurls; i++) { |
|
|
|
char oldurl[INET6_ADDRSTRLEN], oldport[8]; |
|
|
|
char oldurl[INET6_ADDRSTRLEN], oldport[8]; |
|
|
|
char newurl[INET6_ADDRSTRLEN], newport[8]; |
|
|
|
|
|
|
|
char *serverurl = ckp->serverurl[i]; |
|
|
|
char *serverurl = ckp->serverurl[i]; |
|
|
|
|
|
|
|
|
|
|
|
if (!url_from_serverurl(serverurl, newurl, newport)) { |
|
|
|
if (!url_from_serverurl(serverurl, newurl, newport)) { |
|
|
|