X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubox.git;a=blobdiff_plain;f=log%2Flogread.c;h=8c9fda8ec06c42d369d54264519f585aac7c9710;hp=e8749f8ab24aa7d05d7ab1742731aa2b45546c48;hb=f3b07dd3c6eca504cf082e2cf6c0d9e9aa1e91a6;hpb=f8d43c5f222b99d5a7a0e2bd1fdc0d442e030e89 diff --git a/log/logread.c b/log/logread.c index e8749f8..8c9fda8 100644 --- a/log/logread.c +++ b/log/logread.c @@ -303,6 +303,7 @@ int main(int argc, char **argv) const char *ubus_socket = NULL; int ch, ret, subscribe = 0, lines = 0; static struct blob_buf b; + int retry = 5; while ((ch = getopt(argc, argv, "ufcs:l:r:F:p:S:P:h:")) != -1) { switch (ch) { @@ -351,19 +352,24 @@ int main(int argc, char **argv) return -1; } - ret = ubus_lookup_id(ctx, "log", &id); - if (ret) - fprintf(stderr, "Failed to find log object: %s\n", ubus_strerror(ret)); - - if (!subscribe || lines) { - blob_buf_init(&b, 0); - if (lines) - blobmsg_add_u32(&b, "lines", lines); - ubus_invoke(ctx, id, "read", b.head, read_cb, 0, 3000); - } + /* ugly ugly ugly ... we need a real reconnect logic */ + do { + ret = ubus_lookup_id(ctx, "log", &id); + if (ret) { + fprintf(stderr, "Failed to find log object: %s\n", ubus_strerror(ret)); + sleep(1); + continue; + } + if (!subscribe || lines) { + blob_buf_init(&b, 0); + if (lines) + blobmsg_add_u32(&b, "lines", lines); + ubus_invoke(ctx, id, "read", b.head, read_cb, 0, 3000); + } - if (subscribe) - follow_log(ctx, id); + if (subscribe) + follow_log(ctx, id); + } while (ret && retry--); return 0; }