Permalink
Browse files

Merge pull request #68 from ploxiln/pubsub_secondary_cleanup

minimal ps_to_http secondary-pubsub-url fixes
  • Loading branch information...
mreiferson committed Jul 3, 2012
2 parents 647f67d + 9dc1dea commit 0bddc1a00cdbb93681ab965bfa693ce877a4d78a
Showing with 17 additions and 14 deletions.
  1. +17 −14 ps_to_http/ps_to_http.c
View
@@ -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;
@@ -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();

0 comments on commit 0bddc1a

Please sign in to comment.