ubox/logd: free ubus context on exit
[project/ubox.git] / log / logd.c
index 3f80459..0175a5c 100644 (file)
@@ -92,6 +92,9 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
        int ret;
        bool stream = true;
 
+       if (!stream)
+               count = 100;
+
        if (msg) {
                blobmsg_parse(read_policy, __READ_MAX, tb, blob_data(msg), blob_len(msg));
                if (tb[READ_LINES])
@@ -99,8 +102,6 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
                if (tb[READ_STREAM])
                        stream = blobmsg_get_bool(tb[READ_STREAM]);
        }
-       if (!stream)
-               count = 100;
 
        if (pipe(fds) == -1) {
                fprintf(stderr, "logd: failed to create pipe: %s\n", strerror(errno));
@@ -225,6 +226,7 @@ main(int argc, char **argv)
        uloop_run();
        log_shutdown();
        uloop_done();
+       ubus_auto_shutdown(&conn);
 
        return 0;
 }