dbs [Tue, 7 Dec 2010 14:30:45 +0000 (14:30 +0000)]
Apply libtools versioning to OpenSRF c-apps as well
We apply a -version-info argument of 2:0:2, meaning:
* interface = 2: interface '2' of this library
* revision = 0: first implementation of interface '2'
* age = 2: this library can be linked with executables going back
two interface versions
See http://sourceware.org/autobook/autobook/autobook_91.html for more
information on the -version-info argument.
dbs [Tue, 30 Nov 2010 04:16:30 +0000 (04:16 +0000)]
Prepare for version 2.0.0 with versioning for 2.0.0
Use the libtool -version-info option to provide an explicit version
for the libopensrf.so library. Introducing versioned libraries will
give us the ability to force recompiles of linked applications when
binary compatibility has been broken.
erickson [Mon, 29 Nov 2010 19:15:07 +0000 (19:15 +0000)]
add fault tolerance (e.g. recover from interrupted select/sysread); always perform idle maintenance when there are any active child processes; exit check status early when no active processes exist
erickson [Mon, 22 Nov 2010 22:21:35 +0000 (22:21 +0000)]
in the rare case the select() is interrupted while waiting on child statuses, exit early to prevent read()'s on invalid file handles and allow the calling code to loop back around and try again
erickson [Sat, 20 Nov 2010 15:24:55 +0000 (15:24 +0000)]
added support for paging through 'less' (like C); added 'router' query docs; added separate env vars for pretty printing json and for print network object keys; explicit opensrf disconnect on exit
erickson [Tue, 16 Nov 2010 14:08:29 +0000 (14:08 +0000)]
repaired logic in the as-yet-unused import_array_data; use the more efficient enumerate func; capture array length outside of loop for efficiency; avoid calls to set/get_field and access _data directly inside of the NetworkObject class for faster accessor/mutator's
erickson [Tue, 16 Nov 2010 03:36:49 +0000 (03:36 +0000)]
rely on logic, not failure through try/catch, to determine of an object is a registered network object; if an object is unregistered, do not treat it as an __unknown network object (which obfuscates and provides no value).
erickson [Tue, 16 Nov 2010 03:29:32 +0000 (03:29 +0000)]
killed the terminal colors in srfsh.py output. They are cute and all, but are likely the cause of readline oddities/artifacts (and kind of distracting). Default to raw (json) output for consistency
dbs [Thu, 11 Nov 2010 14:47:12 +0000 (14:47 +0000)]
If an alternate config file is pointed to in osrf_ctl.sh, respect it
In a previous edit, I accidentally removed the config file option
from the start_python command, which would break if anything other
than the configured default config file was specified as an option to
osrf_ctl.sh. This makes opensrf.py once again respect the authority
of osrf_ctl.sh.
dbs [Thu, 11 Nov 2010 14:25:02 +0000 (14:25 +0000)]
Use the same PID directory as the opensrf-perl.pl and opensrf.py scripts
The default PID directories for the opensrf-perl.pl and opensrf.py scripts
was /openils/var/run/opensrf (assuming a prefix of '/openils'), while the
default PID directory for osrf_ctl.sh was /openils/var/run. This complicated
matters when trying to restart individual Python or Perl services, as without
passing an explicit PID directory argument the restart command from the
language-specific script would check for a PID in a different PID directory,
find none, and end up running a second copy of the service instead of
restarting the existing service.
The change groups all PIDs in the 'run/opensrf' subdirectory to avoid any
PID file conflicts (as unlikely as that might be) if OpenSRF is installed
in the default location - so rather than /var/local/run/*.pid, one will
be able to look at /var/local/run/opensrf/*.pid
dbs [Tue, 9 Nov 2010 18:17:50 +0000 (18:17 +0000)]
Enhanced do_start() implementation in Python management script
Unclean shutdowns and fork() misery can create PID files that have
no actual process behind them. Instead of just trusting the PID file, check
for the running PID; if the process is not running, then remove the PID file
and actually start the service.
dbs [Tue, 9 Nov 2010 16:21:15 +0000 (16:21 +0000)]
Give opensrf.py reasonable defaults for options
Rather than:
opensrf.py -l -d -f /openils/conf/opensrf_core.xml -p /openils/var/run/ -a start_all
you can now use:
opensrf.py -l -d -a start_all
Isn't that better? Note that we put the PIDs into PID_DIR/run/opensrf/
so that if/when OpenSRF is installed outside of the /openils/ prefix,
the names of the processes won't conflict with any other application PIDs.
Unlikely, but you never know.
dbs [Tue, 9 Nov 2010 14:22:25 +0000 (14:22 +0000)]
Fix daemonize problem that surfaced in start_all
Thanks to Michael Giarlo for reporting the problem, Bill Erickson
for pointing the way to the solution, and http://bugs.python.org/issue5313
for providing me with more context for the problem & solution.
dbs [Mon, 8 Nov 2010 21:03:55 +0000 (21:03 +0000)]
Make opensrf-perl.pl handle missing configuration for services more gracefully
As we might want to ship configuration files with commented out sections,
this will alert the user that a service was listed in the hosts section
but the configuration for that service could not be found.
erickson [Tue, 26 Oct 2010 14:12:15 +0000 (14:12 +0000)]
consistent w/ the C libs, only log server message processing duration at INFO. log server response processing duration at debug and w/ slighly different wording. let the processing duration log message act as the indication of a successfully handled message to reduce logging
scottmk [Thu, 14 Oct 2010 16:30:17 +0000 (16:30 +0000)]
Plug a minor memory leak that could occur when we opened a TCP connection
to a server. In practice this meant whenever we opened a Jabber session.
We call getaddrinfo() to get a dynamically allocated linked list of
addresses for a given server name. Then we traverse the list, looking
for one that accepts streaming connections over IPV4, in order to get
an IP address.
At the end, we call freeaddrinfo() to free the linked list.
Previously we would pass to freeaddrinfo() a pointer, not to the
head of the list, but to the node that we used for getting an IP
address. Prior nodes, if any, would leak.
Also: added calls to freeaddrinfo() in the case of early returns, to
avoid leaking the list in the event of an error.
erickson [Tue, 12 Oct 2010 14:53:41 +0000 (14:53 +0000)]
implemented an optional per-service stderr log for capturing miscellaneous stderr output from services, similar to the old-style _unix.log files, since there are often useful warnings and error messages that never bubble up to syslog. for clarity, the files now use _stderr as a suffix instead of _unix. stderr logs are enabled by default. included opensrf.xml example of how to disable it for a given service
erickson [Tue, 12 Oct 2010 02:58:16 +0000 (02:58 +0000)]
when we add xhr responses onto the end of the queue, stash the original session as well, otherwise we're attempting to ask a session questions about requests it's not tracking
Work around a Net::Domain bug that can result in fqdn's like foo.example.com,bar.com
The bug manifested when trying to run autogen.sh, with the output:
Updating fieldmapper
No Response from settings server...going to sleep
This was because SettingsParser was generating invalid XPath and consquently
errors in the opensrf.settings service; with no response, the attempt to run
autogen.sh would die.
This workaround splits the fqdn on commas and tries each possible domain in
the server setting XPath. Long term we either need to wait for Net::Domain
bug #60729 (https://rt.cpan.org/Public/Bug/Display.html?id=60729) to be
resolved, or consider alternatives.
removing vestigial references to Inbound.pm, which no longer exists in the repository. this also removes get/set_listener, which were never taken advantage of and are no longer of use since the listener is thoroughly hard-coded into the opensrf stack now
Bump trunk version number for OpenSRF up to 1.8.0; better than 1.4.0.
perlmodstyle says "A correct CPAN version number is a floating point
number with at least 2 digits after the decimal." so we're not in
compliance in any case. Oh well.
Update the manifest for Perl modules to avoid build warnings
r2016 removed two Perl modules, src/perl/lib/OpenSRF/Transport/SlimJabber/Inbound.pm
and src/perl/lib/OpenSRF/UnixServer.pm, and the build gets upset because the
manifest suggests they're missing. But no, we know where they are, and we
don't expect them to come back.
gmc [Tue, 31 Aug 2010 20:49:44 +0000 (20:49 +0000)]
remove ntp and ntpdate dependencies
Not used by OpenSRF; these are legacies of
Evergreen dependencies at the time OpenSRF was
split off. Quite likely a bunch of deps in
Makefile.install aren't needed by OpenSRF
proper.
erickson [Wed, 18 Aug 2010 20:11:18 +0000 (20:11 +0000)]
Due to the async nature of xmllhttprequest, processing http responses (which often lead to further async-request laden callbacks) at receive time can result in out-of-order message handling. To bring order to this chaos, push all inbound message onto a queue, then go back to processing the older messages in order of oldest to newest.
scottmk [Mon, 16 Aug 2010 15:18:08 +0000 (15:18 +0000)]
Several minor and inconsequential changes:
1. Tidied up the white space in a few places.
2. Commented out several unused functions, used only for development,
in order to eliminate some annoying compiler warnings.
3. Added the const qualifier to several variables.
4. Added three branches to a switch/case structure, in order to
eliminate some compiler warnings about untested enum values. The
new branches merely issue warning messages to the log (presumably
we don't expect to see RESULT or STATUS messages in this
context).
scottmk [Sat, 14 Aug 2010 11:09:47 +0000 (11:09 +0000)]
Eliminate the old JSON parser, implemented in osrf_json_parser.c and
the associated header osrf_json_utils.h.
This parser has been completely replaced by a newer one implemented
in osrf_parse_json.c, plus an incremental JSON parser (so far
unused) in jsonpush.c..
The even older parser of JSON-with-comments is not affected.
D include/opensrf/osrf_json_utils.h
M include/opensrf/osrf_json.h
D src/libopensrf/osrf_json_parser.c
M src/libopensrf/osrf_json_object.c
M src/libopensrf/Makefile.json
M src/libopensrf/osrf_json_tools.c
M src/libopensrf/Makefile.am
M src/libopensrf/osrf_parse_json.c
M Makefile.am
dbs [Fri, 13 Aug 2010 16:20:01 +0000 (16:20 +0000)]
Make log length in Perl logger a configurable value to assist debugging
If logging to syslog instead of a file, you might need to adjust the
syslog configuration to accept longer than its own default lengths of
log messages
dbs [Fri, 13 Aug 2010 16:16:05 +0000 (16:16 +0000)]
First cut at adding Debian Squeeze to OpenSRF prerequisite installer
Along the way, make a few other changes:
* drop Debian Etch and Gentoo support
* add dscott@laurentian.ca to the author list
* remove Class::DBI as that's actually a prereq for Evergreen, not OpenSRF
scottmk [Tue, 10 Aug 2010 02:13:39 +0000 (02:13 +0000)]
Provide a way for a service to set the effective buffer size for a
specified method.
Non-atomic methods accumulate RESULT messages into a buffer, from which
they are flushed when the buffer is about to overflow, or when the
closing STATUS message is issued.
The new osrfMethodSetBufferSize() function allows the service to favor
large buffers (for greater throughput) or small ones (for a lower
latency for the first response).
Since the buffersize is not an absolute limit, the effective buffer
size may be set to zero, in which case each RESULT message will be
packaged and sent in a separate XMPP message as soon as it is ready.
Changing the buffer size has no effect on an atomic method, nor on a
method that returns only one RESULT message.
M include/opensrf/osrf_application.h
M src/libopensrf/osrf_application.c
scottmk [Mon, 9 Aug 2010 16:18:05 +0000 (16:18 +0000)]
Cruft removal; there should be no outwardly visible effects.
1. Remove the OSRF_METHOD_ATOMIC and OSRF_METHOD_SYSTEM options
from the interface functions osrfRegisterMethod() and
osrfRegisterExtendedMethod().
An application cannot usefully apply these options when it registers
a method, and if it tries, it will almost certainly not work as
intended anyway.
This change required considerable refactoring of the code
responsible for registering methods.
2. When the attempt to initialize an application fails, remove
the application from the application list and destroy it,
instead of keeping it around in an unusable state.
3. Eliminate some redundant lookups of application by name
when registering system methods.
M include/opensrf/osrf_application.h
M src/libopensrf/osrf_application.c
scottmk [Mon, 9 Aug 2010 12:31:33 +0000 (12:31 +0000)]
Fixed a bug in the chunking.
Short version: The non-atomic system methods weren't working. Now
they are.
Long version: When a method returns a value greater than zero, a
post-processing step sends a STATUS message to signify that the
response is complete. In the old code this post-processing
bypassed the buffer-flushing step, so that anything still in the
buffer didn't get sent.
The non-atomic system methods returned positive return codes and
were therefore subject to this problem. I don't know if any
non-system methods return postive return codes, but if they do,
they would also have been affected.
scottmk [Wed, 4 Aug 2010 03:20:33 +0000 (03:20 +0000)]
Implement the chunking of OSRF messages. I.e. bundle multiple
OSRF messages into an XMPP message, up to about 10k bytes, so
as to reduce networking overhead.
M include/opensrf/osrf_application.h
M src/libopensrf/osrf_application.c
1. Add a buffer to osrfAppSession structure; for future use
2. New function osrfSendTransportPayload(). This a repackaging of
existing functionality pulled out into a separate function so that
it can be reused in other contexts.
These changes are preparation for future changes, and will have no
visible effect by themselves.
M include/opensrf/osrf_app_session.h
M src/libopensrf/osrf_app_session.c
Add response chunking support to the Perl implementation of OpenSRF
Two new optional paramters to register_method are now supported:
* max_chunk_size
* max_chunk_count
OpenSRF has always supported message bundling, but only respond_complete made
use of this fact by sending the final result message and the completion status
message in the same XMPP envelope. Now, on a per method basis, RESULT messages
can be bundled (cached) until one of three conditions occurs:
* The size of the JSON of the RESULT messages matches or exceeds max_chunk_size
* The number of RESULT messages cached matches or exceeds max_chunk_count
* respond_complete is called (which happens implicitly by returning from a method)
Because the overhead of sending multiple XMPP messages far outweighs the caching
and cache management costs of chunking, the default for max_chunk_size is set
at 10240 bytes (10k). The default for max_chunk_count is 0. To turn off chunking
completely, set the max_chunk_size register_method parameter to 0.
1. Make osrfMessageToJSON() available at global scope.
2. New function osrf_message_set_result() -- a more efficient alternative
to osrf_message_set_result_content().
Typically when using the older function, we convert a jsonObject to JSON
text, and then parse the JSON text back into a jsonObject. With the new
function we can avoid the round trip through the text format.
M include/opensrf/osrf_message.h
M src/libopensrf/osrf_message.c
scottmk [Tue, 22 Jun 2010 04:23:09 +0000 (04:23 +0000)]
Rearrange the way that a listener juggles its drones.
Instead of maintaining a single circular linked list including both active
processes and idle processes, keep the active drones in the circular list
and the idle drones in a separate linear list; move them back and forth
as needed. This change simplifies how we search for drones when we need
them, because we don't have to skip over ones that we don't want.
The list of idle drones acts as a stack. When we look for an idle drone
for a new request, we pick the one at the head of the list, which is the
last one to have become idle.
As a result, we pick the drone that is most likely still to be in memory.
In the old arrangment, the list acted as a queue. When picking an idle
drone, we picked the one that had been idle the longest -- which was the
one most likely to have been swapped out.
Also: added a number of doxygen-style comments, and tinkered with the
white space here and there.
Note: an earlier commit tried to make similar changes, but it had to be
backed out because it mangled the linkage pointers in some situations,
leading to segfaults. That problem has now been corrected.
dbs [Tue, 15 Jun 2010 14:03:58 +0000 (14:03 +0000)]
Rename example Apache configuration file to include ".conf" suffix
This is useful on systems like Fedora that require the .conf suffix to act
on files in a conf.d subdirectory, and is generally useful for visually
distinguishing the purpose of the file.