queue_proc.cb = queue_proc_cb;
uloop_fd_add(&hotplug_fd, ULOOP_READ);
}
+
+void hotplug_shutdown(void)
+{
+ uloop_fd_delete(&hotplug_fd);
+ close(hotplug_fd.fd);
+}
#include <libubox/uloop.h>
void hotplug(char *rules);
+void hotplug_shutdown(void);
void hotplug_last_event(uloop_timeout_handler handler);
#endif
void debug_init(void);
void procd_connect_ubus(void);
+void procd_reconnect_ubus(int reconnect);
void ubus_init_service(struct ubus_context *ctx);
void ubus_init_log(struct ubus_context *ctx);
void ubus_init_system(struct ubus_context *ctx);
klog_open();
openlog("procd", LOG_PID, LOG_DAEMON);
}
+
+void log_shutdown(void)
+{
+ ustream_free(&slog.stream);
+ ustream_free(&klog.stream);
+ close(slog.fd.fd);
+ close(klog.fd.fd);
+}
};
void log_init(void);
+void log_shutdown(void);
typedef void (*log_list_cb)(struct log_head *h);
struct log_head* log_list(int count, struct log_head *h);
#include "procd.h"
#include "watchdog.h"
+#include "hotplug.h"
#define HOSTNAME_PATH "/proc/sys/kernel/hostname"
return 0;
}
+static int system_upgrade(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ procd_reconnect_ubus(0);
+ log_shutdown();
+ hotplug_shutdown();
+
+ return 0;
+}
+
enum {
WDT_FREQUENCY,
WDT_TIMEOUT,
static const struct ubus_method system_methods[] = {
UBUS_METHOD_NOARG("info", system_info),
+ UBUS_METHOD_NOARG("upgrade", system_upgrade),
UBUS_METHOD("watchdog", watchdog_set, watchdog_policy),
};
static struct ubus_context *ctx;
static struct uloop_process ubus_proc;
static bool ubus_connected = false;
+static int reconnect = 1;
static void procd_ubus_connection_lost(struct ubus_context *old_ctx);
static void procd_ubus_connection_lost(struct ubus_context *old_ctx)
{
+ if (!reconnect)
+ return;
+
procd_ubus_try_connect();
while (!ubus_connected) {
procd_restart_ubus();
procd_ubus_connection_lost(NULL);
}
+void procd_reconnect_ubus(int _reconnect)
+{
+ reconnect = _reconnect;
+}
+