* avoid unneccessary and wrong incantation of apr_thread_exit. The two
sub-threads now both live for the duration of the process.
* to be safe, create thread mutex before threads
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
It was falling behind the shared lib in bug fixes and features. A
per-tab WS implementation is (maybe) a dangerous thing to have around,
as well, since it encourages /many/ connections. Can resurrect later if
needed.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Mon, 3 Mar 2014 15:29:23 +0000 (10:29 -0500)]
LP#1268619: websocket: avoid module auto configuration
We don't want osrf_websocket_translator to be directly loaded as a
module, since it is not an apache module, but a shared library loaded by
an apache module (mod_websockets). This is especially true of the default
apache instance.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Added support for an idle timeout and idle check interval configuration
variables. These allow each websocket apache process to kick off
clients that have been connected and are idle for too long, thus hogging
a process unnecessarily.
Added a SIGUSR1 signal handler which forces the idle timeout to be very
low and a short re-check period so that the client can be kicked as soon
as there are no open conversations.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
* starting packet inspection
* activity log; recipient removal
* only cache connected recipients; use request_rec pool for session_pool parent
* wrap all thread work in mutex
* session memory goodness
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
* use jsonObjectFree() on jsonObjets, not free();
* removed some debugging logs
* accommodate API changes for Apache 2.4
* safer logging:
Avoid using ap_log_rerror, in particular referencing server->request
from the responder thread, since the request_rec will be invalid after
on_disconnect is called.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
OpenSRF can run mutiple times, as different users, on one host.
Right now we look for all service processes, but we should only
look for our own. This patch does that.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
LP#1285915: document that perl2JSON doesn't order hash keys
This patch documents that JSON strings returned by
OpenSRF::Utils::JSON->perl2JSON() should not be expected to have
hash keys sorted in any particular order. It also adjusts a
corresponding test case to consistently pass under Perl 5.18, which
introduces hash order randomization.
Forcing JSON output to be in canonical form is another option, and
easily done by JSON::XS, but would add overhead.
Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Bill Erickson <berick@esilibrary.com>
LP#1234816: improve const-correctness of osrfCachePutString and osrfCachePutObject
Since the cache key is not modified by osrfCachePutString and
osrfCachePutObject, this patch changes the key parameter of those
two functions from char* to const char*. It also updates one
caller osrfCachePutObject to not cast away const-ness.
This patch has no functional impact, but enables future callers
of osrfCachePut* to pass constant strings without having to
cast away the const-ness.
Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Bill Erickson <berick@esilibrary.com>
This script is no longer user, since ejabberdctrl is used instead.
What's more, this script uses a Perl package (libnet-jabber-perl) which
is no longer available in Debian (Jessie).
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Docgen output would be a bit more useful if it respected the formatting
(such as it is) of the signature content provided by the developer. So,
let's make that happen.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Instead of simply producing an error message in the OpenSRF logs, calls
to nonexistent subroutines are now fatal errors which will stop code
execution.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Fri, 12 Oct 2012 20:57:15 +0000 (16:57 -0400)]
LP#1066131: srfsh.py should not require opensrf.settings
Update srfsh.py to connect to the opensrf network without automatically
reading the opensrf.setting server data. This allows srfsh.py to run a
non-private network.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Tue, 7 Jan 2014 19:06:06 +0000 (14:06 -0500)]
osrf_control router-de/re-register and reload commands
Added support for the following new command line options:
--router-de-register
--router-de-register-all
Sends a SIGUSR1 signal to the selected service(s), which causes each
service's listener process to send an "unregister" command to all
registered routers. The --all variant sends the signal to all
running listeners. The non-(--all) variant requires a --service.
--router-re-register
--router-re-register-all
Sends a SIGUSR2 signal to the selected service(s), which causes each
service's listener process to send a "register" command to all
configured routers routers. The --all variant sends the signal to
all running listeners. The non-(--all) variant requires a --service.
--reload
--reload-all
Sends a SIGHUP signal to the selected service(s). SIGHUP causes
each Listener process to reload its opensrf_core.xml config file
and gracefully re-launch drone processes. The -all variant sends
the signal to all services. The non-(-all) variant requires a
--service.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Tue, 7 Jan 2014 19:06:06 +0000 (14:06 -0500)]
osrf_control router-de/re-register and reload commands
Added support for the following new command line options:
--router-de-register
--router-de-register-all
Sends a SIGUSR1 signal to the selected service(s), which causes each
service's listener process to send an "unregister" command to all
registered routers. The --all variant sends the signal to all
running listeners. The non-(--all) variant requires a --service.
--router-re-register
--router-re-register-all
Sends a SIGUSR2 signal to the selected service(s), which causes each
service's listener process to send a "register" command to all
configured routers routers. The --all variant sends the signal to
all running listeners. The non-(--all) variant requires a --service.
--reload
--reload-all
Sends a SIGHUP signal to the selected service(s). SIGHUP causes
each Listener process to reload its opensrf_core.xml config file
and gracefully re-launch drone processes. The -all variant sends
the signal to all services. The non-(-all) variant requires a
--service.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Thu, 21 Nov 2013 21:37:38 +0000 (16:37 -0500)]
recover osrf_control router start
With the addition of service verification, which ensures that a service
is meant to run on the requested host, we lost the ability to start the
router by itself, since the router is never explicitly configured to run
anywhere. This patch assumes the router is always a valid service.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Dan Wells <dbw2@calvin.edu>
Bill Erickson [Thu, 21 Nov 2013 21:37:38 +0000 (16:37 -0500)]
recover osrf_control router start
With the addition of service verification, which ensures that a service
is meant to run on the requested host, we lost the ability to start the
router by itself, since the router is never explicitly configured to run
anywhere. This patch assumes the router is always a valid service.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Dan Wells <dbw2@calvin.edu>
Bill Erickson [Thu, 5 Dec 2013 17:27:44 +0000 (12:27 -0500)]
OpenSRF client disconnect robustification (Perl)
* Improve detection of client connection state with jabber server
Be more aggressive in testing and responding to failed connectivity.
It can happen in various ways, depending on what's happening to the
jabber server (death, delay, graceful shutdown). With these changes
we attempt to cover all the bases and detect as early as possible that
a connection has died, specifically when trying to create a new
connection after one has failed.
* Do a better job of cleaning up dead connections
Transport::PeerHandle now has a reset() action which disconnects (when
possible) and clears the global connection reference.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Thu, 5 Dec 2013 17:27:44 +0000 (12:27 -0500)]
OpenSRF client disconnect robustification (Perl)
* Improve detection of client connection state with jabber server
Be more aggressive in testing and responding to failed connectivity.
It can happen in various ways, depending on what's happening to the
jabber server (death, delay, graceful shutdown). With these changes
we attempt to cover all the bases and detect as early as possible that
a connection has died, specifically when trying to create a new
connection after one has failed.
* Do a better job of cleaning up dead connections
Transport::PeerHandle now has a reset() action which disconnects (when
possible) and clears the global connection reference.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Mike Rylander [Thu, 16 May 2013 14:17:15 +0000 (10:17 -0400)]
Protect subrequests from post-complete messages
Subrequests (AKA method_lookup()-based API calls) sometimes append
final-lvalue responses to the response list even after respond_complete()
has been called from within the implementation method. This commit
discards all post-respond_complete values, protecting against extra,
spurious values being returned to the ultimate client.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Mike Rylander [Thu, 16 May 2013 14:17:15 +0000 (10:17 -0400)]
Protect subrequests from post-complete messages
Subrequests (AKA method_lookup()-based API calls) sometimes append
final-lvalue responses to the response list even after respond_complete()
has been called from within the implementation method. This commit
discards all post-respond_complete values, protecting against extra,
spurious values being returned to the ultimate client.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
The patch for bug 1204123 changes the client_recv()
to not set the transport_client error flag, as most
of the circumstances where it would have been set were
for cases where the call to select() was interrupted
by a signal, which is not an error per se.
This patch removes two tests that were therefore
made invalid, restoring the ability of the test suite
to pass.
Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Bill Erickson <berick@esilibrary.com>
Any time a start action is issued (start, start_all, restart,
restart_all), osrf_control will first verify that the selected hostname
(or localhost) hosts the requested service(s). If not, the user is
warned and the script exits before any action is taken.
Note: we do not make a similar verification for stop and signal actions,
since those may be reasonably be used even when a service is not
configured to run on the selected host.
Thanks to Jason Stephenson for the suggestion.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Bill Erickson [Tue, 27 Aug 2013 15:47:52 +0000 (11:47 -0400)]
C SIGHUP handling and config reloading
Sending the HUP signal to a C Listener process now results in the
following:
* Reload the opensrf_core config
* update the log file level
* kill idle child processes
* child processes that are active when the signal is received are
tracked and killed once they become idle.
* New children are spawned per the min child settings
The primary use case for these changes is temporarily changing the log
level for a given service for debug purposes. It may also
be used, for example, to gracefully recover excess RAM consumed by a
child process.
opensrf.xml (opensrf.settings config) is not reloaded, so min/max child
settings will not be affected.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Bill Erickson [Mon, 12 Aug 2013 15:33:11 +0000 (11:33 -0400)]
LP1204123 install opensrf-perl.pl as osrf_control
Symlink osrf_control to opensrf-perl.pl to act as the replacement for
osrf_ctl.sh. I chose "osrf_control" since it matches more closely to
"osrf_config" -- also it's probably less confusing than calling it
osrf_ctl, which would likely get confused w/ osrf_ctl.sh
TODO: documentation
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Bill Erickson [Fri, 9 Aug 2013 14:40:29 +0000 (10:40 -0400)]
LP1204123 opensrf-perl.pl expansion continued
* improved cleanup of stale pid files during startup
* added --force-clean-process option to kill orphan (no pidfile)
processes during startup
* other minor cleanup
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
opensrf-perl.pl can now stop/start/signal/etc. all opensrf services,
regardless of language. It is in effect a replacement for osrf_ctl.sh
with considerably broader powers.
To ease transition, osrf_ctl.sh has been taught to pass
start/stop/restart_all commands through to opensrf-perl.pl.
The layout of commands has changed some (e.g. --start-all instead of
--action start_all) and a host of new commands have been added.
Below are the full set of commands. See --help for full descriptions:
Bill Erickson [Wed, 31 Jul 2013 21:43:12 +0000 (17:43 -0400)]
LP1204123 Improved per-service control (C/Perl)
C opensrf no longer mantains a single master process. Instead, like
Perl, each Listener process writes its own PID file and can be managed
individually. Related to this, much code was cleaned up in
osrf_system.c.
osrf_ctl.sh now has the ability to stop/start individual services for
Perl and C, using the new -s <service> option. Examples:
osrf_ctl.sh -l -a restart_c -s opensrf.math
osrf_ctl.sh -l -a restart_perl -s opensrf.settings
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Bill Erickson [Wed, 24 Jul 2013 20:28:15 +0000 (16:28 -0400)]
LP1204123 Don't treat interrupts as errors
Interrupted calls to select() are generally not errors, but more likely
signals received by the process. Avoid setting the transport_client
error flag to true in these cases. Otherwise, after one signal is
received, no other outbound communication can occur on the client
connection.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
When a listener process receives the USR2 signal, the 'register' command
is sent to all known routers. This allows for the addition of new
routers to running opensrf services.
If a register command is sent to a router for which the process is
already successfully register, the router will safely discard it, so
multiple SIGUSR2 calls are safe.
Minor int => bool clarification repair to existing C shutdown
(prefork_clear) code.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
now sport an additional "reload" boolean parameter. When set, the settings
file (opensrf.xml) will be reloaded from the file system to pick up any
changes which have occurred since the last load/reload.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Bill Erickson [Mon, 22 Jul 2013 20:44:26 +0000 (16:44 -0400)]
LP1204123 SIGTERM graceful shutdown (C)
When a TERM signal is received, the listener parent process will wait
for all child processes to complete any active tasks before killing the
child processes and shutting down.
Receiving a SIGINT or SIGQUIT results in a non-graceful shutdown.
In all cases, the system first un-registers with all routers.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
The listener process will unregister all router connections. This
allows services to remove themselves from consideration for new
inbound requests while allowing their drone processes to complete
any currently running tasks.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Bill Erickson [Fri, 21 Jun 2013 20:43:01 +0000 (16:43 -0400)]
LP1204123 SIGTERM causes graceful shutdown (Perl)
When sent the SIGTERM signal, listener processes will wait for all child
processes to complete their currently running tasks before killing all
child processes and exiting.
SIGQUIT and SIGINT can still be used for semi-graceful shutdowns, where
the listener de-registers and cleans up child processes, but does not
wait for child processes to finish their tasks.
To kill with fire, SIGKILL is still your friend.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Bill Erickson [Wed, 26 Jun 2013 18:51:52 +0000 (14:51 -0400)]
LP1204123 Set SIGCHLD handler to DEFAULT for children (perl)
Remove the special SIGCHLD handler applied to the parent/listener
process from spawned child processes (drones) by setting child handler to
DEFAULT. Otherwise, if an OpenSRF drone process spawns a sub-process,
the drone will execute the SIGCHLD handler meant for the Listener when
the sub-process dies, wherein hijinks ensue.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Get/set the locale used by all new client sessions
for the current process. This is primarily useful
for clients that wish to make a series of opensrf
calls and don't wish to set the locale for each new
AppSession object.
The caller should reset the locale when done using
reset_locale(), as the locale will otherwise persist
for the current process until set/reset again.
This is not for SERVER processes, since they
adopt the locale of their respective callers.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>