Commit 82089655 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/wrsw_hal: use shmem instead of ipc to check if HAL is running

Until now, ipc client was created in HAL to check if another HAL instance is
running. It has been changed to use shmem for the same purpose.

To prevent error from linker, order of linking libraries had to be changed.

Additionally developer manual was updated.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 4a0b7064
......@@ -1525,12 +1525,6 @@ Clients are created in the following places:
actions related to vlan setup. All status information is passed
through shared memory.
@item userspace/wrsw_hal/hal_exports.c
@c FIXME: don't check with a socket, but with the shmem mechanism
A temporary client is created to check whether a HAL process
is already running.
@item userspace/tools/wr_mon.c
@c FIXME: wr_mon should use shmem
......
......@@ -23,7 +23,7 @@ CFLAGS = -O -g -Wall \
-I$(LINUX)/arch/arm/mach-at91/include
LDFLAGS = -L../libwr -L../mini-rpc \
-lminipc -lm -ldl -lwr
-lm -ldl -lwr -lminipc
all: $(BINARY)
......
......@@ -2,6 +2,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <libwr/wrs-msg.h>
#include <libwr/pps_gen.h> /* for direct access to DMPLL and PPS generator */
......@@ -10,6 +13,7 @@
#include <rt_ipc.h>
#include <minipc.h>
#include <libwr/shmem.h>
#define HAL_EXPORT_STRUCTURES
#include <hal/hal_exports.h> /* for exported structs/function protos */
......@@ -212,11 +216,20 @@ int hal_update_wripc(int ms_timeout)
to prevent from launching multiple HALs simultaneously. */
int hal_check_running()
{
struct minipc_ch *ch;
struct wrs_shm_head *hal_head;
hal_head = wrs_shm_get(wrs_shm_hal, "", WRS_SHM_READ);
if (!hal_head) {
pr_info("Unable to open shm for HAL! Unable to check if there "
"is another HAL instance running. Error: %s\n",
strerror(errno));
exit(-1);
}
ch = minipc_client_create(WRSW_HAL_SERVER_ADDR, 0);
if (!ch)
/* check if pid is 0 (shm not filled) or process with provided
* pid does not exist (probably crashed) */
if ((hal_head->pid == 0) || (kill(hal_head->pid, 0) != 0))
return 0;
minipc_close(ch);
wrs_shm_put(hal_head);
return 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment