Use common /var/run/rpcd base directory to store runtime information
This commit is contained in:
parent
b4649c9fda
commit
fa53571f2b
4 changed files with 12 additions and 5 deletions
|
@ -32,7 +32,7 @@
|
|||
|
||||
#define RPC_SID_LEN 32
|
||||
#define RPC_DEFAULT_SESSION_TIMEOUT 300
|
||||
#define RPC_SESSION_DIRECTORY "/var/run/rpcd"
|
||||
#define RPC_SESSION_DIRECTORY "/var/run/rpcd/sessions"
|
||||
|
||||
struct rpc_session {
|
||||
struct avl_node avl;
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <libubus.h>
|
||||
#include <uci.h>
|
||||
|
||||
#define RPC_UCI_SAVEDIR_PREFIX "/var/run/rpcd/uci-"
|
||||
|
||||
int rpc_uci_api_init(struct ubus_context *ctx);
|
||||
|
||||
void rpc_uci_purge_savedirs(void);
|
||||
|
|
5
main.c
5
main.c
|
@ -22,6 +22,7 @@
|
|||
#include <libubox/blobmsg_json.h>
|
||||
#include <libubus.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <rpcd/session.h>
|
||||
#include <rpcd/uci.h>
|
||||
|
@ -58,6 +59,7 @@ exec_self(int argc, char **argv)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct stat s;
|
||||
const char *hangup;
|
||||
const char *ubus_socket = NULL;
|
||||
int ch;
|
||||
|
@ -72,6 +74,9 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (stat("/var/run/rpcd", &s))
|
||||
mkdir("/var/run/rpcd", 0700);
|
||||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
signal(SIGHUP, handle_signal);
|
||||
signal(SIGUSR1, handle_signal);
|
||||
|
|
8
uci.c
8
uci.c
|
@ -185,7 +185,7 @@ rpc_uci_set_savedir(struct blob_attr *sid)
|
|||
}
|
||||
|
||||
snprintf(path, sizeof(path) - 1,
|
||||
"/tmp/.uci-rpc-%s", (char *)blobmsg_data(sid));
|
||||
RPC_UCI_SAVEDIR_PREFIX "%s", blobmsg_get_string(sid));
|
||||
|
||||
uci_set_savedir(cursor, path);
|
||||
}
|
||||
|
@ -1151,12 +1151,12 @@ rpc_uci_purge_savedir_cb(struct rpc_session *ses, void *priv)
|
|||
{
|
||||
char path[PATH_MAX];
|
||||
|
||||
snprintf(path, sizeof(path) - 1, "/tmp/.uci-rpc-%s", ses->id);
|
||||
snprintf(path, sizeof(path) - 1, RPC_UCI_SAVEDIR_PREFIX "%s", ses->id);
|
||||
rpc_uci_purge_savedir(path);
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes all delta directories which match the /tmp/.uci-rpc-* pattern.
|
||||
* Removes all delta directories which match the RPC_UCI_SAVEDIR_PREFIX.
|
||||
* This is used to clean up garbage when starting rpcd.
|
||||
*/
|
||||
void rpc_uci_purge_savedirs(void)
|
||||
|
@ -1164,7 +1164,7 @@ void rpc_uci_purge_savedirs(void)
|
|||
int i;
|
||||
glob_t gl;
|
||||
|
||||
if (!glob("/tmp/.uci-rpc-*", 0, NULL, &gl))
|
||||
if (!glob(RPC_UCI_SAVEDIR_PREFIX "*", 0, NULL, &gl))
|
||||
{
|
||||
for (i = 0; i < gl.gl_pathc; i++)
|
||||
rpc_uci_purge_savedir(gl.gl_pathv[i]);
|
||||
|
|
Loading…
Reference in a new issue