Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

minimal ps_to_http secondary-pubsub-url fixes

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...
commit 9dc1dea9df10d4248cb6f0be5db2cde6f27aed41 1 parent 647f67d
Pierce Lopez authored
Showing with 17 additions and 14 deletions.
  1. +17 −14 ps_to_http/ps_to_http.c
View
31 ps_to_http/ps_to_http.c
@@ -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();
Please sign in to comment.
Something went wrong with that request. Please try again.