2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 2.1
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <sys/resource.h>
22 char *ubus_socket
= NULL
;
23 static struct ubus_context
*ctx
;
24 static struct uloop_timeout ubus_timer
;
27 ubus_reconnect_cb(struct uloop_timeout
*timeout
)
29 if (!ubus_reconnect(ctx
, ubus_socket
))
32 uloop_timeout_set(timeout
, 2000);
36 ubus_disconnect_cb(struct ubus_context
*ctx
)
38 ubus_timer
.cb
= ubus_reconnect_cb
;
39 uloop_timeout_set(&ubus_timer
, 2000);
43 ubus_connect_cb(struct uloop_timeout
*timeout
)
45 ctx
= ubus_connect(ubus_socket
);
48 DEBUG(4, "Connection to ubus failed\n");
49 uloop_timeout_set(&ubus_timer
, 1000);
53 ctx
->connection_lost
= ubus_disconnect_cb
;
54 ubus_init_service(ctx
);
55 ubus_init_system(ctx
);
57 DEBUG(2, "Connected to ubus, id=%08x\n", ctx
->local_id
);
62 procd_connect_ubus(void)
64 ubus_timer
.cb
= ubus_connect_cb
;
65 uloop_timeout_set(&ubus_timer
, 1000);