Browse Source

Simplify send_subscribe code

master
Con Kolivas 10 years ago
parent
commit
1d69aa0ae9
  1. 17
      src/generator.c

17
src/generator.c

@ -1133,11 +1133,11 @@ static proxy_instance_t *proxy_by_id(gdata_t *gdata, const int id)
static proxy_instance_t *current_proxy(gdata_t *gdata); static proxy_instance_t *current_proxy(gdata_t *gdata);
static char *get_subscribe(ckpool_t *ckp, proxy_instance_t *proxi) static void send_subscribe(ckpool_t *ckp, proxy_instance_t *proxi)
{ {
gdata_t *gdata = ckp->data; gdata_t *gdata = ckp->data;
json_t *json_msg; json_t *json_msg;
char *msg; char *msg, *buf;
JSON_CPACK(json_msg, "{sisssisb}", JSON_CPACK(json_msg, "{sisssisb}",
"proxy", proxi->id, "proxy", proxi->id,
@ -1146,7 +1146,10 @@ static char *get_subscribe(ckpool_t *ckp, proxy_instance_t *proxi)
"reconnect", proxi == current_proxy(gdata) ? true : false); "reconnect", proxi == current_proxy(gdata) ? true : false);
msg = json_dumps(json_msg, JSON_NO_UTF8); msg = json_dumps(json_msg, JSON_NO_UTF8);
json_decref(json_msg); json_decref(json_msg);
return msg; ASPRINTF(&buf, "subscribe=%s", msg);
free(msg);
send_proc(ckp->stratifier, buf);
free(buf);
} }
static void send_notify(gdata_t *gdata, int *sockd, const char *buf) static void send_notify(gdata_t *gdata, int *sockd, const char *buf)
@ -1413,14 +1416,8 @@ out:
/* Close and invalidate the file handle */ /* Close and invalidate the file handle */
Close(cs->fd); Close(cs->fd);
} else { } else {
char *msg, *buf;
keep_sockalive(cs->fd); keep_sockalive(cs->fd);
msg = get_subscribe(ckp, proxi); send_subscribe(ckp, proxi);
ASPRINTF(&buf, "subscribe=%s", msg);
free(msg);
send_proc(ckp->stratifier, buf);
free(buf);
proxi->notified = false; proxi->notified = false;
} }
return ret; return ret;

Loading…
Cancel
Save