From 08b741ed056297d22665d576df6b7a4f0d5c1e8a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 19 Apr 2021 11:08:49 -0700 Subject: [PATCH] ca: fallback to repeater thread if unable to exec caRepeater Silently fallback to in-process repeater thread on all targets. Including on host targets when caRepeater executable is unavailable. --- documentation/RELEASE_NOTES.md | 16 ++++++++++++++++ modules/ca/src/client/udpiiu.cpp | 7 ++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 792e67874..8e17ce35d 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -17,6 +17,22 @@ should also be read to understand what has changed since earlier releases. +### Automatic fallback to thread when unable to exec caRepeater + +A process using libca which does not find an existing caRepeater process +will attempt to start one by running the caRepeater executable. +This is not always possible, usually when caRepeater is not in `$PATH`. +Now, instead of printing a warning, an internal caRepeater thread +will be started (as is done be RTEMS and vxWorks targets). + +If this fallback occurs, the lifetime of the caRepeater thread +may be shorter than the lifetime of a separate caRepeater process +would have been. + +It remains the recommended practice to explicitly start a caRepeater +instance. Examples of both systemd (`caRepeater.service`) and sysv +(`S99caRepeater`) scripts may be found under `bin/`. + ### Glob pattern allowed in `var` command When used with one argument, the `var` command can be used with a glob pattern diff --git a/modules/ca/src/client/udpiiu.cpp b/modules/ca/src/client/udpiiu.cpp index ba1caa99b..723117a71 100644 --- a/modules/ca/src/client/udpiiu.cpp +++ b/modules/ca/src/client/udpiiu.cpp @@ -629,8 +629,8 @@ void epicsStdCall caStartRepeaterIfNotInstalled ( unsigned repeaterPort ) * repeater's port) */ osiSpawnDetachedProcessReturn osptr = - osiSpawnDetachedProcess ( "CA Repeater", "caRepeater" ); - if ( osptr == osiSpawnDetachedProcessNoSupport ) { + osiSpawnDetachedProcess ( "!CA Repeater", "caRepeater" ); + if ( osptr != osiSpawnDetachedProcessSuccess ) { epicsThreadId tid; tid = epicsThreadCreate ( "CAC-repeater", epicsThreadPriorityLow, @@ -639,9 +639,6 @@ void epicsStdCall caStartRepeaterIfNotInstalled ( unsigned repeaterPort ) fprintf ( stderr, "caStartRepeaterIfNotInstalled : unable to create CA repeater daemon thread\n" ); } } - else if ( osptr == osiSpawnDetachedProcessFail ) { - fprintf ( stderr, "caStartRepeaterIfNotInstalled (): unable to start CA repeater daemon detached process\n" ); - } } }