Skip to content

Commit

Permalink
lightningd/plugin: use ld's timer loop.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jun 30, 2019
1 parent ef541af commit 98de92c
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <common/timeout.h>
#include <dirent.h>
#include <errno.h>
#include <lightningd/io_loop_with_timers.h>
#include <lightningd/json.h>
#include <lightningd/lightningd.h>
#include <lightningd/notification.h>
Expand Down Expand Up @@ -77,7 +78,6 @@ struct plugins {
struct log *log;
struct log_book *log_book;

struct timers timers;
struct lightningd *ld;
};

Expand Down Expand Up @@ -107,7 +107,6 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
list_head_init(&p->plugins);
p->log_book = log_book;
p->log = new_log(p, log_book, "plugin-manager");
timers_init(&p->timers, time_mono());
p->ld = ld;
return p;
}
Expand Down Expand Up @@ -969,7 +968,6 @@ void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
struct plugin *p;
char **cmd;
int stdin, stdout;
struct timer *expired;
struct jsonrpc_request *req;
plugins->pending_manifests = 0;
uintmap_init(&plugins->pending_requests);
Expand Down Expand Up @@ -1009,19 +1007,15 @@ void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
p->timeout_timer = NULL;
else {
p->timeout_timer
= new_reltimer(&plugins->timers, p,
= new_reltimer(plugins->ld->timers, p,
time_from_sec(PLUGIN_MANIFEST_TIMEOUT),
plugin_manifest_timeout, p);
}
tal_free(cmd);
}
while (plugins->pending_manifests > 0) {
void *v = io_loop(&plugins->timers, &expired);
if (v == plugins)
break;
if (expired)
timer_expired(plugins, expired);
}

if (plugins->pending_manifests > 0)
io_loop_with_timers(plugins->ld);
}

static void plugin_config_cb(const char *buffer,
Expand Down

0 comments on commit 98de92c

Please sign in to comment.