Move client_t lat/lng over in live upgrade, so that m/ filter works for unvalidated clients right after live upgrade, too.

This commit is contained in:
Heikki Hannikainen 2015-09-11 08:48:12 +03:00
parent e7666c5f6b
commit 74d4d019fb
2 changed files with 16 additions and 0 deletions

View File

@ -1081,6 +1081,7 @@ static int accept_liveupgrade_single(cJSON *client, int *rxerr_map, int rxerr_ma
cJSON *filter;
cJSON *ibuf, *obuf;
cJSON *client_heard;
cJSON *lat, *lng;
unsigned addr_len;
union sockaddr_u sa;
char *argv[256];
@ -1124,6 +1125,8 @@ static int accept_liveupgrade_single(cJSON *client, int *rxerr_map, int rxerr_ma
ibuf = cJSON_GetObjectItem(client, "ibuf");
obuf = cJSON_GetObjectItem(client, "obuf");
client_heard = cJSON_GetObjectItem(client, "client_heard");
lat = cJSON_GetObjectItem(client, "lat");
lng = cJSON_GetObjectItem(client, "lng");
if (!(
(fd)
@ -1283,6 +1286,14 @@ static int accept_liveupgrade_single(cJSON *client, int *rxerr_map, int rxerr_ma
if (rx_errs && rx_errs->type == cJSON_Array && rxerr_map && rxerr_map_len > 0)
accept_rx_err_load(c, rx_errs, rxerr_map, rxerr_map_len);
/* set client lat/lon, if they're given
*/
if (lat && lng && lat->type == cJSON_Number && lng->type == cJSON_Number) {
c->loc_known = 1;
c->lat = lat->valuedouble;
c->lng = lng->valuedouble;
}
hlog(LOG_DEBUG, "%s - Accepted live upgrade client on fd %d from %s", c->addr_loc, c->fd, c->addr_rem);
/* set client socket options, return -1 on serious errors */

View File

@ -2141,6 +2141,11 @@ static struct cJSON *worker_client_json(struct client_t *c, int liveup_info)
cJSON_AddNumberToObject(jc, "heard_count", c->client_heard_count);
cJSON_AddNumberToObject(jc, "courtesy_count", c->client_courtesy_count);
if (c->loc_known) {
cJSON_AddNumberToObject(jc, "lat", c->lat);
cJSON_AddNumberToObject(jc, "lng", c->lng);
}
if (c->quirks_mode)
cJSON_AddNumberToObject(jc, "quirks_mode", c->quirks_mode);