diff options
-rw-r--r-- | hotplug.c | 6 | ||||
-rw-r--r-- | hotplug.h | 1 | ||||
-rw-r--r-- | procd.h | 1 | ||||
-rw-r--r-- | syslog.c | 8 | ||||
-rw-r--r-- | syslog.h | 1 | ||||
-rw-r--r-- | system.c | 13 | ||||
-rw-r--r-- | ubus.c | 9 |
7 files changed, 39 insertions, 0 deletions
@@ -434,3 +434,9 @@ void hotplug(char *rules) 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); +} @@ -18,6 +18,7 @@ #include <libubox/uloop.h> void hotplug(char *rules); +void hotplug_shutdown(void); void hotplug_last_event(uloop_timeout_handler handler); #endif @@ -47,6 +47,7 @@ extern unsigned int debug; 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); @@ -276,3 +276,11 @@ void log_init(void) 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); +} @@ -31,6 +31,7 @@ struct log_head { }; 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); @@ -24,6 +24,7 @@ #include "procd.h" #include "watchdog.h" +#include "hotplug.h" #define HOSTNAME_PATH "/proc/sys/kernel/hostname" @@ -55,6 +56,17 @@ static int system_info(struct ubus_context *ctx, struct ubus_object *obj, 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, @@ -120,6 +132,7 @@ static int watchdog_set(struct ubus_context *ctx, struct ubus_object *obj, 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), }; @@ -23,6 +23,7 @@ char *ubus_socket = NULL; 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); @@ -84,6 +85,9 @@ static void procd_ubus_try_connect(void) static void procd_ubus_connection_lost(struct ubus_context *old_ctx) { + if (!reconnect) + return; + procd_ubus_try_connect(); while (!ubus_connected) { procd_restart_ubus(); @@ -101,3 +105,8 @@ void procd_connect_ubus(void) procd_ubus_connection_lost(NULL); } +void procd_reconnect_ubus(int _reconnect) +{ + reconnect = _reconnect; +} + |