X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=ubus.c;h=e87543aeef73a09ff2403a4c8952ae40d9b06e83;hb=9961e88dd853a30503298378679d2cedc497410e;hp=0bd9e499c567c9034bbda80909f17bbcbfa9960a;hpb=e0d721487a618490a7db06f76904868a71684071;p=project%2Fprocd.git diff --git a/ubus.c b/ubus.c index 0bd9e49..e87543a 100644 --- a/ubus.c +++ b/ubus.c @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Felix Fietkau + * Copyright (C) 2013 John Crispin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include #include #include #include @@ -21,7 +36,7 @@ static void procd_restart_ubus(void) char *argv[] = { "ubusd", NULL, ubus_socket, NULL }; if (ubus_proc.pending) { - DPRINTF("Killing existing ubus instance, pid=%d\n", (int) ubus_proc.pid); + ERROR("Killing existing ubus instance, pid=%d\n", (int) ubus_proc.pid); kill(ubus_proc.pid, SIGKILL); uloop_process_delete(&ubus_proc); } @@ -31,16 +46,17 @@ static void procd_restart_ubus(void) ubus_proc.pid = fork(); if (!ubus_proc.pid) { + setpriority(PRIO_PROCESS, 0, -20); execvp(argv[0], argv); exit(-1); } if (ubus_proc.pid <= 0) { - DPRINTF("Failed to start new ubus instance\n"); + ERROR("Failed to start new ubus instance\n"); return; } - DPRINTF("Launched new ubus instance, pid=%d\n", (int) ubus_proc.pid); + DEBUG(1, "Launched new ubus instance, pid=%d\n", (int) ubus_proc.pid); uloop_process_add(&ubus_proc); } @@ -53,13 +69,17 @@ static void procd_ubus_try_connect(void) ctx = ubus_connect(ubus_socket); if (!ctx) { - DPRINTF("Connection to ubus failed\n"); + DEBUG(2, "Connection to ubus failed\n"); return; } ctx->connection_lost = procd_ubus_connection_lost; ubus_connected = true; - procd_init_service(ctx); + ubus_init_service(ctx); + if (getpid() == 1) { + ubus_init_log(ctx); + ubus_init_system(ctx); + } } static void procd_ubus_connection_lost(struct ubus_context *old_ctx) @@ -71,7 +91,7 @@ static void procd_ubus_connection_lost(struct ubus_context *old_ctx) procd_ubus_try_connect(); } - DPRINTF("Connected to ubus, id=%08x\n", ctx->local_id); + DEBUG(1, "Connected to ubus, id=%08x\n", ctx->local_id); ubus_add_uloop(ctx); }