Hi Hans N,
My 2 cents..
1. Instead of LOG_ER() better call sigalrm_handler(0).
+ if (signal(SIGALRM, sigalrm_handler) == SIG_ERR) {
+ LOG_ER("signal ALRM failed: %s", strerror(errno));
+ }
2. Why cannot the timeout logic can derive/bind directly from/to the
timeout value ("i_timeout_in_ms" of NCS_OS_PROC_EXECUTE_TIMED_INFO
structure). Say..,
Example: alarm_time_sec = (i_timeout_in_ms/2000); /* say
(half or lesser) of CLC-CLI timeout value in seconds. */
3. I prefer the kind of patch should go into a major release (4.4) not
for minor releases (4.3.x/4.2.x).
Thanks,
Ramesh.
On 7/22/2013 5:07 PM, Hans Nordeback wrote:
> osaf/libs/core/leap/os_defs.c | 27 +++++++++++++++++++++++++++
> 1 files changed, 27 insertions(+), 0 deletions(-)
>
>
> amfnd calls ncs_os_process_execute_timed and the child process takes too long
> time before exec, (10 sec timeout). An alarm is set in the
> ncs_os_process_execute_timed child process. If timed out a core dump will be
> produced to be able to trouble shoot.
>
> diff --git a/osaf/libs/core/leap/os_defs.c b/osaf/libs/core/leap/os_defs.c
> --- a/osaf/libs/core/leap/os_defs.c
> +++ b/osaf/libs/core/leap/os_defs.c
> @@ -65,6 +65,15 @@ bool gl_ncs_atomic_mtx_initialise = fals
> * description of SOCK_CLOEXEC. */
> static pthread_mutex_t s_cloexec_mutex = PTHREAD_MUTEX_INITIALIZER;
>
> +/*
> + * ALRM signal is used to detect if child process takes too long time before
> exec.
> + *
> + * @param sig
> + */
> +static void sigalrm_handler(int sig)
> +{
> + abort();
> +}
> /***************************************************************************
> *
> * uns64
> @@ -999,6 +1008,22 @@ uint32_t ncs_os_process_execute_timed(NC
> osaf_mutex_lock_ordie(&s_cloexec_mutex);
>
> if ((pid = fork()) == 0) {
> + unsigned int alarm_time_sec;
> + char* alarm_time;
> +
> + if (signal(SIGALRM, sigalrm_handler) == SIG_ERR) {
> + LOG_ER("signal ALRM failed: %s", strerror(errno));
> + }
> + if ((alarm_time =
> getenv("OPENSAF_CHILD_EXEC_TIME_TOLERANCE")) != NULL) {
> + alarm_time_sec = strtol(alarm_time, NULL, 0);
> + }
> + else {
> + // default alarm timeout 2 seconds
> + alarm_time_sec = 2;
> + }
> +
> + alarm(alarm_time_sec);
> +
> /*
> ** Make sure forked processes have default scheduling class
> ** independent of the callers scheduling class.
> @@ -1054,6 +1079,8 @@ uint32_t ncs_os_process_execute_timed(NC
> }
> #endif
>
> + alarm(0);
> +
> /* child part */
> if (execvp(req->i_script, req->i_argv) == -1) {
> syslog(LOG_ERR, "%s: execvp '%s' failed - %s",
> __FUNCTION__, req->i_script, strerror(errno));
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel