Skip to content

Commit

Permalink
minimal ps_to_http secondary-pubsub-url fixes
Browse files Browse the repository at this point in the history
don't print ERROR when no secondary-pubsub-url has been specified
delete timer before setting it again for secondary-pubsub-url
  • Loading branch information
Pierce Lopez committed Jun 29, 2012
1 parent 647f67d commit 9dc1dea
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions ps_to_http/ps_to_http.c
Expand Up @@ -175,7 +175,7 @@ void free_destination_urls()
int main(int argc, char **argv)
{
char *pubsub_url;
char *secondary_pubsub_url = NULL;
char *secondary_pubsub_url;
char *address;
int port;
char *path;
Expand Down Expand Up @@ -215,23 +215,26 @@ int main(int argc, char **argv)
} else {
fprintf(stderr, "ERROR: failed to parse pubsub_url\n");
}
if (secondary_pubsub_url && simplehttp_parse_url(secondary_pubsub_url, strlen(secondary_pubsub_url), &address, &port, &path)) {
if (secondary_pubsub_url) {
if (simplehttp_parse_url(secondary_pubsub_url, strlen(secondary_pubsub_url), &address, &port, &path)) {
pubsubclient_init(address, port, path, process_message_cb, error_cb, NULL);

if (option_get_int("max_silence") > 0) {
_DEBUG("Registering timer.\n");
max_silence_time.tv_sec = option_get_int("max_silence");
evtimer_set(&silence_ev, silence_cb, NULL);
evtimer_add(&silence_ev, &max_silence_time);
}
if (option_get_int("max_silence") > 0) {
_DEBUG("Registering timer.\n");
max_silence_time.tv_sec = option_get_int("max_silence");
evtimer_del(&silence_ev);
evtimer_set(&silence_ev, silence_cb, NULL);
evtimer_add(&silence_ev, &max_silence_time);
}

pubsubclient_run();
pubsubclient_run();

free(address);
free(path);
free(secondary_pubsub_url);
} else {
fprintf(stderr, "ERROR: failed to parse secondary_pubsub_url\n");
free(address);
free(path);
free(secondary_pubsub_url);
} else {
fprintf(stderr, "ERROR: failed to parse secondary_pubsub_url\n");
}
}

free_destination_urls();
Expand Down

0 comments on commit 9dc1dea

Please sign in to comment.