Print error if parsing service JSON fails
[project/mdnsd.git] / service.c
index 36d20c74830ed783b7ca272c63977b2dd93a4064..f21578d00caa38e98e7e0f262a98af5785338c33 100644 (file)
--- a/service.c
+++ b/service.c
@@ -65,7 +65,7 @@ service_update(struct vlist_tree *tree, struct vlist_node *node_new,
 
 static struct blob_buf b;
 static VLIST_TREE(services, avl_strcmp, service_update, false, false);
-char *sdudp =  "_services._dns-sd._udp.local";
+const char *sdudp =  "_services._dns-sd._udp.local";
 static int service_init_announce;
 
 static const char *
@@ -255,9 +255,12 @@ service_load(char *path)
 
        for (i = 0; i < gl.gl_pathc; i++) {
                blob_buf_init(&b, 0);
-               if (blobmsg_add_json_from_file(&b, gl.gl_pathv[i]))
+               if (blobmsg_add_json_from_file(&b, gl.gl_pathv[i])) {
                        blob_for_each_attr(cur, b.head, rem)
                                service_load_blob(cur);
+               } else {
+                       fprintf(stderr, "Error reading %s JSON\n", gl.gl_pathv[i]);
+               }
        }
        globfree(&gl);
 }
@@ -271,7 +274,7 @@ service_init_cb(struct ubus_request *req, int type, struct blob_attr *msg)
        get_hostname();
 
        vlist_update(&services);
-       service_load("/tmp/run/mdns/*");
+       service_load("/etc/umdns/*");
 
        blob_for_each_attr(cur, msg, rem) {
                struct blob_attr *cur2;