|
|
@ -101,6 +101,7 @@ struct proxy_instance { |
|
|
|
bool notified; /* Received new template for work */ |
|
|
|
bool notified; /* Received new template for work */ |
|
|
|
bool diffed; /* Received new diff */ |
|
|
|
bool diffed; /* Received new diff */ |
|
|
|
bool reconnect; /* We need to drop and reconnect */ |
|
|
|
bool reconnect; /* We need to drop and reconnect */ |
|
|
|
|
|
|
|
bool replaced; /* This proxy has issued a reconnect with new data */ |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_t notify_lock; |
|
|
|
pthread_mutex_t notify_lock; |
|
|
|
notify_instance_t *notify_instances; |
|
|
|
notify_instance_t *notify_instances; |
|
|
@ -855,12 +856,13 @@ static bool parse_reconnect(proxy_instance_t *proxi, json_t *val) |
|
|
|
newsi->id = ckp->proxies++; |
|
|
|
newsi->id = ckp->proxies++; |
|
|
|
ckp->servers = realloc(ckp->servers, sizeof(server_instance_t *) * ckp->proxies); |
|
|
|
ckp->servers = realloc(ckp->servers, sizeof(server_instance_t *) * ckp->proxies); |
|
|
|
ckp->servers[newsi->id] = newsi; |
|
|
|
ckp->servers[newsi->id] = newsi; |
|
|
|
ckp->chosen_server = newsi->id; |
|
|
|
|
|
|
|
newsi->url = url; |
|
|
|
newsi->url = url; |
|
|
|
newsi->auth = strdup(si->auth); |
|
|
|
newsi->auth = strdup(si->auth); |
|
|
|
newsi->pass = strdup(si->pass); |
|
|
|
newsi->pass = strdup(si->pass); |
|
|
|
proxi->reconnect = true; |
|
|
|
proxi->reconnect = true; |
|
|
|
|
|
|
|
proxi->replaced = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Reuse variable on a new proxy instance */ |
|
|
|
proxi = ckzalloc(sizeof(proxy_instance_t)); |
|
|
|
proxi = ckzalloc(sizeof(proxy_instance_t)); |
|
|
|
newsi->data = proxi; |
|
|
|
newsi->data = proxi; |
|
|
|
proxi->auth = newsi->auth; |
|
|
|
proxi->auth = newsi->auth; |
|
|
@ -868,6 +870,9 @@ static bool parse_reconnect(proxy_instance_t *proxi, json_t *val) |
|
|
|
proxi->si = newsi; |
|
|
|
proxi->si = newsi; |
|
|
|
proxi->ckp = ckp; |
|
|
|
proxi->ckp = ckp; |
|
|
|
proxi->cs = &newsi->cs; |
|
|
|
proxi->cs = &newsi->cs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set chosen server only once all new proxy data exists */ |
|
|
|
|
|
|
|
ckp->chosen_server = newsi->id; |
|
|
|
out: |
|
|
|
out: |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
@ -1346,6 +1351,9 @@ static bool proxy_alive(ckpool_t *ckp, server_instance_t *si, proxy_instance_t * |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool ret = false; |
|
|
|
bool ret = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (proxi->replaced) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
/* Has this proxy already been reconnected? */ |
|
|
|
/* Has this proxy already been reconnected? */ |
|
|
|
if (cs->fd > 0) |
|
|
|
if (cs->fd > 0) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|