scottmk [Wed, 5 Aug 2009 22:27:04 +0000 (22:27 +0000)]
Extended the JSON_INIT_CLEAR macro to avoid segfaults.
Scenario: converting a JSON_BOOL, with a value of true, to a JSON_HASH or
JSON_ARRAY. The true value (in a union with an osrfHash* and an osrfList*)
was being interpreted as a non_NULL pointer and deferenced. Oops.
With this change, we clear the boolean value (by nullifying one of the
unioned pointers) whenever changing from a JSON_BOOL to anything else.
scottmk [Wed, 5 Aug 2009 12:53:19 +0000 (12:53 +0000)]
Performance tweak to jsonIterator.
Instead of storing a malloc'd copy of the key of a JSON_HASH entry,
just store a const pointer to the key string stored in the
internal osrfHash. That way we don't have to do a malloc and
free every time we bump the iterator.
This change also requires the addition of a couple of const qualifiers
in the client code.
This is a performance tweak to the osrfHashGet function, a widely
used utility function.
The old version accepted a variable number of arguments: a pointer
to an osrfHash, a string optionally containing printf-style
format specifiers, and addtional parameters as needed to fill in
the blanks.
In practice, none of the code ever uses the printf-style formatting.
We always pass exactly two parameters. We burn CPU cycles scanning
the string for format specifiers and never find any.
I eliminated the unused variable parameters and turned osrfHashGet()
into a simple two-parameter function. Just in case anybody ever
wants it, I also cloned the original version into a new function
named osrfHashGetFmt, which accepts a variable number of arguments
as before.
Note that, since the signature of the function is changing,
it is necessary to recompile any open-ils programs that
call it, namely:
Add two new commands, "open" and "close", to open and close ongoing
connections to specified services. (Otherwise a connection is created
and destroyed for every request.)
Main purpose: to be able to use srfsh for database operations that require
transactions.
Warning: typically the <keepalive> value will need to be increased for
the service in question in opensrf.xml, or else the server will close
the connection before you can type your request.
erickson [Thu, 11 Jun 2009 13:10:36 +0000 (13:10 +0000)]
until we make the router / C processes write their own PID file, put a short sleep in after startup to give each time to show up in the 'ps' output. this should help prevent lingering router processes after service stop
erickson [Wed, 10 Jun 2009 21:46:00 +0000 (21:46 +0000)]
added a session_data disctionary to ServerSession class for storing per-session data. fixed bug where no params caused serer-side confusion. added exmample of session_data usage to example app
erickson [Wed, 3 Jun 2009 15:58:20 +0000 (15:58 +0000)]
flush_socket now flushes data through the xml stream parser to prevent the destorying the validity of the stream. now discarding RESULT messages passed to server sessions.
dbs [Sun, 31 May 2009 19:49:00 +0000 (19:49 +0000)]
Use autotools a bit more to our advantage:
* In osrf_ctl.sh, use the configured location for osrf_config by default
* Differentiate between prefix and exec_prefix to respect configure options
* Make configure output slightly more consistent
scottmk [Tue, 31 Mar 2009 18:30:10 +0000 (18:30 +0000)]
1. Create a new osrfListExtract function, which removes an item
from an osrfList without destroying it, and returns a pointer to
the item thus removed.
2. Create a new jsonObjectExtractIndex, which removes a
specified entry in a JSON_ARRAY, and returns a pointer
to it, without destroying it.
3. In osrf_json.h: Corrected an inaccurate comment about
jsonObjectRemoveIndex(). Contrary to the original comment, this
function does not shift other objects down to fill the gap.
scottmk [Tue, 31 Mar 2009 12:45:53 +0000 (12:45 +0000)]
In osrf_system_shutdown(): provide a return value for an early
return (since the function is of type int).
It's not clear whether these are the right semantics, since we
never capture the return value anyway. But if we're going
to return anything at all, it makes sense to return something
different in the case of an early return.
erickson [Tue, 17 Feb 2009 17:47:18 +0000 (17:47 +0000)]
not sure why this is an issue now (different perl/json:xs verions?), but
$obj->{$k} = JSONObject2Perl($bool)
results in 'Modification of a read-only value attempted', while
$obj->{$k} = $bool
does not, even though the JSON::XS::Boolean object is not altered by JSONObject2Perl().
just missing something?
patched
scottmk [Thu, 29 Jan 2009 03:58:26 +0000 (03:58 +0000)]
This update mainly tightens the error handling.
1. If there aren't enough arguments on the command line, return EXIT_FAILURE
instead of zero.
2. Defer the call to set_proc_title() until we are done using the command
line arguments, so that we don't have to make copies of them.
3. Check the return value from osrfConfigInit(). Otherwise a NULL (caused,
e.g., by a missing config file) leads to a segfault.
4. If the config file doesn't define any routers to spawn, exit immediately
with an error message before entering the fork loop.
5. If a child process returns (due to an error) instead of entering the
normal endless loop, break out of the fork loop. Otherwise the child
remains in the fork loop and spawns children of its own (unless it's the
last child to be spawned). At best, that's just silly.
6. Append an newline to a message issued from setupRouter(). (It's not
clear why this message goes directly to stderr instead of to the usual
logging machinery, which at this point is directed to stderr anyway.)
scottmk [Thu, 15 Jan 2009 02:05:24 +0000 (02:05 +0000)]
Add a new function osrfStringArrayTokenize. It parses an input
string into tokens separated by a specified delimiter character,
much like strtok() or strtok_r(), and loads them into an
osrfStringArray.
scottmk [Wed, 14 Jan 2009 14:36:14 +0000 (14:36 +0000)]
Add a function osrfMethodVerifyContext() to do what the
existing OSRF_METHOD_VERIFY_CONTEXT macro does. Use it in
_osrfAppRunSystemMethod() and osrfAppEcho().
erickson [Tue, 13 Jan 2009 20:33:01 +0000 (20:33 +0000)]
need a copy of the service when it's pulled from the cache, since the sessionCache object is freed. use apr_pstrdup so Apache will manage the memory for us
scottmk [Mon, 12 Jan 2009 05:35:10 +0000 (05:35 +0000)]
1. Replaced the innards of an osrfStringArray to include an
osrfList instead of a pointer to an osrfList. This change
eliminates a layer of malloc and free when creating and
destroying an osrfStringArray. It also eliminates a layer
of indirection when performing other operations.
2. Eliminated the prototype for string_array_get_total_size(),
since no such function exists.
3. Added the const qualifier to various function parameters.
scottmk [Sun, 11 Jan 2009 22:11:34 +0000 (22:11 +0000)]
In the macro OSRF_LIST_GET_INDEX: placed all occurrences of the macro arguments
in parentheses, to prevent unexpected effects when one or more of the
arguments is an expression.
scottmk [Fri, 9 Jan 2009 20:14:35 +0000 (20:14 +0000)]
Move the xmlSAXHandler out of the header and into the
implementation file, along with the prototypes of the
associated callback functions (which are now static)
scottmk [Fri, 9 Jan 2009 18:51:01 +0000 (18:51 +0000)]
Move the xmlSAXHandler out of the header and into the
implementation file, along with the declarations of the
associated callback functions (which are now static)