summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
authorThierry Carré2013-03-19 17:57:59 +0100
committerThierry Carré2013-04-26 17:03:11 +0200
commit0c9ea0dd478057f76fe3d12cfaedc8501f176351 (patch)
tree50b56e9b00c9dc350c4cf915395210bebe2eee2c /cleopatre
parentc51e3f1fa766b2ca946cd348bed03f020c8beb80 (diff)
cleo/devkit/plcd: save pid in plcd context
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/devkit/plcd/inc/plcd_ctx.h2
-rw-r--r--cleopatre/devkit/plcd/src/plcd_main.c20
2 files changed, 11 insertions, 11 deletions
diff --git a/cleopatre/devkit/plcd/inc/plcd_ctx.h b/cleopatre/devkit/plcd/inc/plcd_ctx.h
index af23c883c9..793bfe8293 100644
--- a/cleopatre/devkit/plcd/inc/plcd_ctx.h
+++ b/cleopatre/devkit/plcd/inc/plcd_ctx.h
@@ -94,6 +94,8 @@ typedef struct
{
/** Pointer on the program name (argv[0]). */
const char *my_name;
+ /** PID of plcd. */
+ pid_t pid;
/** full path of HPAV info file */
const char *hpav_info_path;
/** full path of HPAV config file */
diff --git a/cleopatre/devkit/plcd/src/plcd_main.c b/cleopatre/devkit/plcd/src/plcd_main.c
index 5dadd26448..95fbefbe87 100644
--- a/cleopatre/devkit/plcd/src/plcd_main.c
+++ b/cleopatre/devkit/plcd/src/plcd_main.c
@@ -124,7 +124,6 @@ plcd_init (plcd_ctx_t *ctx)
char was_cco_str[LIBSPID_BOOLEAN_STR_MAX_LEN] = {0};
struct plcdrv_setpid user_data;
struct ifreq ifr;
- pid_t pid = getpid ();
PLCD_ASSERT (NULL != ctx);
@@ -163,7 +162,7 @@ plcd_init (plcd_ctx_t *ctx)
}
memset (&ctx->plcd_addr, 0, sizeof (ctx->plcd_addr));
ctx->plcd_addr.nl_family = AF_NETLINK;
- ctx->plcd_addr.nl_pid = pid; /* self pid */
+ ctx->plcd_addr.nl_pid = ctx->pid;
ctx->plcd_addr.nl_groups = 0; /* not in mcast group */
if (0 > bind (ctx->plc_sock, (struct sockaddr *) &ctx->plcd_addr,
sizeof (ctx->plcd_addr)))
@@ -174,7 +173,7 @@ plcd_init (plcd_ctx_t *ctx)
/* Set plcd pid for reception on drv netlink */
user_data.nl = NETLINK_PLC_DRV;
- user_data.pid = pid;
+ user_data.pid = ctx->pid;
ifr.ifr_data = (void *) &user_data;
strncpy (ifr.ifr_name, (char*) PLC_IFNAME, IFNAMSIZ);
if (0 > (ioctl (ctx->plc_sock, PLCDRV_IOCTL_SETPID, &ifr)))
@@ -248,20 +247,18 @@ plcd_daemon_main (plcd_ctx_t *ctx)
exit (EXIT_FAILURE);
}
- pid_t pid = getpid ();
-
/* register to hpav.conf and hpav.info files update */
if ((LIBSPID_SUCCESS != libspid_system_file_update_register (
- pid, LIBSPID_HPAV_CONF_PATH, plcd_signal_handler))
+ ctx->pid, LIBSPID_HPAV_CONF_PATH, plcd_signal_handler))
|| (LIBSPID_SUCCESS != libspid_system_file_update_register (
- pid, LIBSPID_HPAV_INFO_PATH, plcd_signal_handler)))
+ ctx->pid, LIBSPID_HPAV_INFO_PATH, plcd_signal_handler)))
{
exit (EXIT_FAILURE);
}
/* register to mcast.info file update */
if (libspid_system_file_update_register (
- pid, LIBSPID_MULTICAST_INFO_PATH, plcd_signal_handler)
+ ctx->pid, LIBSPID_MULTICAST_INFO_PATH, plcd_signal_handler)
!= LIBSPID_SUCCESS)
{
exit (EXIT_FAILURE);
@@ -282,9 +279,9 @@ plcd_daemon_main (plcd_ctx_t *ctx)
}
}
- libspid_system_file_update_unregister (pid, LIBSPID_HPAV_CONF_PATH);
- libspid_system_file_update_unregister (pid, LIBSPID_HPAV_INFO_PATH);
- libspid_system_file_update_unregister (pid, LIBSPID_MULTICAST_INFO_PATH);
+ libspid_system_file_update_unregister (ctx->pid, LIBSPID_HPAV_CONF_PATH);
+ libspid_system_file_update_unregister (ctx->pid, LIBSPID_HPAV_INFO_PATH);
+ libspid_system_file_update_unregister (ctx->pid, LIBSPID_MULTICAST_INFO_PATH);
}
}
@@ -306,6 +303,7 @@ plcd_main_init (plcd_ctx_t *ctx, const char *name)
ctx->phy_conf_path = LIBSPID_PHY_CONF_PATH;
ctx->internal_conf_path = LIBSPID_INTERNAL_CONF_PATH;
ctx->my_name = name;
+ ctx->pid = getpid ();
}
/**