Browse Source

Inherit serverurl correctly when none is specified

master
Con Kolivas 9 years ago
parent
commit
9e17bec09c
  1. 13
      src/connector.c
  2. 4
      src/stratifier.c

13
src/connector.c

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

4
src/stratifier.c

@ -7568,10 +7568,6 @@ void *stratifier(void *arg)
if (!ckp->proxy)
sdata->blockchange_id = sdata->workbase_id = randomiser;
if (!ckp->serverurls) {
ckp->serverurl[0] = "127.0.0.1";
ckp->serverurls = 1;
}
cklock_init(&sdata->instance_lock);
cksem_init(&sdata->update_sem);
cksem_post(&sdata->update_sem);

Loading…
Cancel
Save