12 years agoadded some debug logging
erickson [Wed, 19 Mar 2008 17:13:48 +0000 (17:13 +0000)]
added some debug logging

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded session/request locale support
erickson [Wed, 19 Mar 2008 15:25:38 +0000 (15:25 +0000)]
added session/request locale support

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoupdated to match new opensrf_core.xml domain layout
erickson [Wed, 19 Mar 2008 14:10:08 +0000 (14:10 +0000)]
updated to match new opensrf_core.xml domain layout

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agofor easier debugging, logging method and params on NULL return
erickson [Tue, 18 Mar 2008 17:52:43 +0000 (17:52 +0000)]
for easier debugging, logging method and params on NULL return

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPlug for a a memory leak from Scott McKellar
miker [Sun, 16 Mar 2008 18:18:27 +0000 (18:18 +0000)]
Plug for a a memory leak from Scott McKellar

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoupdated srfsh math_bench return value since json no longer returns the extra 0s
erickson [Wed, 12 Mar 2008 21:12:34 +0000 (21:12 +0000)]
updated srfsh math_bench return value since json no longer returns the extra 0s

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar which removes harmful use of osrf_clearbuf()
miker [Wed, 12 Mar 2008 01:09:03 +0000 (01:09 +0000)]
Patch from Scott McKellar which removes harmful use of osrf_clearbuf()

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoforcing router exit without friendly cleanup for now until a socket bug is squashed
erickson [Tue, 11 Mar 2008 22:03:28 +0000 (22:03 +0000)]
forcing router exit without friendly cleanup for now until a socket bug is squashed

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoas it turns out, this was actually a problem with the makefile, not the utils.h macro...
erickson [Tue, 11 Mar 2008 16:49:41 +0000 (16:49 +0000)]
as it turns out, this was actually a problem with the makefile, not the utils.h macro def.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agorolling back change in changeset 1277 for default osrf_clearbuf handling. not sure...
erickson [Tue, 11 Mar 2008 14:40:55 +0000 (14:40 +0000)]
rolling back change in changeset 1277 for default osrf_clearbuf handling.  not sure of the exact problem yet, suffice to say the services wont start with the "!!!..." version of clearbuf enabled

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar providing speed improvement by using fread() instead of...
miker [Mon, 10 Mar 2008 13:37:44 +0000 (13:37 +0000)]
Patch from Scott McKellar providing speed improvement by using fread() instead of fgets()

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 10 Mar 2008 13:32:28 +0000 (13:32 +0000)]
Patch from Scott McKellar:

1. Pedantic: I changed child_dead from an int to a sig_atomic_t, since
we set it from a signal handler.

2. In check_children() and prefork_child_wait(), we prepare an input
buffer for a read() by calling the osrf_clearbuf macro.  Depending on
the existence of NDEBUG, this macro may or may not do the right thing.
If it does the wrong thing, it will pad the input data with
exclamation points, up to the maximimum length.

I added code to explicitly add a terminal nul, thus rendering
the osrf_clearbuf macro both harmless and superfluous.

This issue is the same one that I mentioned yesterday in connection
with socket_bundle.c, so I shall not belabor it here.

3. In addition: in check_children() I arranged to issue the debug
message only if the read is successful.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoParially, a patch from Scott McKellar:
miker [Mon, 10 Mar 2008 13:10:59 +0000 (13:10 +0000)]
Parially, a patch from Scott McKellar:

1. In socket_open_unix_server() and socket_open_unix_client(), I added
checks to make sure that the path parameter doesn't point to aomething
too big to fit into the receiving buffer of the struct sockaddr_un.

2. In _socket_handle_client_data() I add a terminal nul to the data
received by recv().

Also, reversing the semantics and default of NDEBUG per.  To turn on debugging
code, set DEBUG to 1 durring the build:

 $ DEBUG=1 make clean all

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 10 Mar 2008 12:04:57 +0000 (12:04 +0000)]
Patch from Scott McKellar:

This patch replaces several calls to fprintf() or printf() with calls
to fputs(), where we don't use conversion specifications.

Since fputs() doesn't have to parse the output text for conversions,
it should be marginally more efficient than fprintf() or printf().

More importantly: in one case the output text comes in part from an
input message, and may conceivably contain conversion specifications,
whether inadvertently or maliciously.  In that case, fprintf() would
look for non-existent parameters to format into the output, resulting
in undefined behavior.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoConst correctness patch from Scott McKellar
miker [Mon, 10 Mar 2008 05:51:09 +0000 (05:51 +0000)]
Const correctness patch from Scott McKellar

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoConst correctness patch from Scott McKellar.
miker [Mon, 10 Mar 2008 04:53:26 +0000 (04:53 +0000)]
Const correctness patch from Scott McKellar.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agosmall memory leak plugged by Scott McKellar in the math-bench test app
miker [Mon, 10 Mar 2008 04:07:53 +0000 (04:07 +0000)]
small memory leak plugged by Scott McKellar in the math-bench test app

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 10 Mar 2008 03:53:04 +0000 (03:53 +0000)]
Patch from Scott McKellar:

This patch plugs a memory leak in osrfSystemBootstrapClientResc().
We were leaking log_file in the case of an early return.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 10 Mar 2008 03:02:07 +0000 (03:02 +0000)]
Patch from Scott McKellar:

This patch plugs a memory leak that I somehow missed earlier, and
adds a few performance tweaks.

1. In osrfRouterFree() I added a line to free the osrfHash to which
the classes member points.

2. I replaced an occurrence of "jsonParseString("[]")" with
"jsonNewObjectType(JSON_ARRAY)", a call that produces the same
result with a lot less overhead.

3. For similar reasons I replaced several occurrences of
"jsonParseString("{}")" with "jsonNewObjectType(JSON_HASH)".

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 10 Mar 2008 02:54:12 +0000 (02:54 +0000)]
Patch from Scott McKellar:

These patches mostly concern the jsonObjectFindPath function in
osrf_json_tools.c, along with a couple of related functions.  They
plug some memory leaks and boost performance.

1. In osrf_json.h: I moved the nested #includes inside the compilation

2. In osrf_json_utils.h: I added a compilation guard.

3. I moved the declarations of _jsonObjectF_jsonObjectFindPathRecurse
and __jsonObjectF_jsonObjectFindPathRecurse out of the header and into
the implementation file, and made them both static.

4. I also renamed those functions to findMultiPath and
findMultiPathRecurse, respectively, so that their names wouldn't be
confusingly similar.

5. In both functions, and in the parent function jsonObjectFindPath(),
I added the const qualifier to the character pointer parameters.

6. In jsonObjectFindPath(): we were leaking pathcopy in the case of
an early return.  Besides plugging that leak, I rearranged the logic
so that we don't allocate pathcopy unless we actually have a use for

7. Also in jsonObjectFindPath(): I eliminated a call to strlen(), and
the redundant variable t.

8. In _jsonObjectFindPathRecurse() (now findMultiPath()) we were
leaking newarr in the case of an early return.  Besides plugging that
leak, I rearranged the logic so that we don't allocate newarr unless
we actually have a use for it.

9. In a couple of spots I replaced "jsonParseString("[]")" with
"jsonNewObjectType(JSON_ARRAY)", a call that produces the same result
with a lot less overhead.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 10 Mar 2008 02:25:39 +0000 (02:25 +0000)]
Patch from Scott McKellar:

This patch plugs a memory leak and tweaks a couple of minor things.

1. In osrfCacheGetObject() I added the const qualifier to the "data"
variable, since we don't write through that pointer.

2. In osrfCacheGetString() I corrected an error message that claimed
to be coming from a different function.

3. In osrfCacheSetExpire() we were leaking a jsonObject allocated by
osrfCacheGetObject().  I contrived to free it.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 10 Mar 2008 02:21:03 +0000 (02:21 +0000)]
Patch from Scott McKellar:

In _jsonInsertParserItem() I changed a switch/case to an if/else,
eliminating a supposedly unreachable default branch that, if reached,
would leak memory.

With this change, a jsonObject that is neither a JSON_HASH nor a
JSON_ARRAY will be silently converted to a JSON_ARRAY by the call to

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadding service name to the "stopping process.." log line
erickson [Mon, 10 Mar 2008 01:14:03 +0000 (01:14 +0000)]
adding service name to the "stopping process.." log line

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded special case to avoid wrapping boolean objects
erickson [Sun, 9 Mar 2008 01:16:48 +0000 (01:16 +0000)]
added special case to avoid wrapping boolean objects

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadd JSON::XS-based true/false support
miker [Sun, 9 Mar 2008 01:02:20 +0000 (01:02 +0000)]
add JSON::XS-based true/false support

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agomade the pid file reading smarter. removed the nasty killalls since they are no...
erickson [Fri, 7 Mar 2008 22:33:48 +0000 (22:33 +0000)]
made the pid file reading smarter.  removed the nasty killalls since they are no longer necessary

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded a basic signal handler for the top-level C process which sends SIGTERM to its...
erickson [Fri, 7 Mar 2008 22:32:42 +0000 (22:32 +0000)]
added a basic signal handler for the top-level C process which sends SIGTERM to its children to clean up

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded support for blocking connect and request calls
erickson [Thu, 6 Mar 2008 21:32:27 +0000 (21:32 +0000)]
added support for blocking connect and request calls

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded connect-only handling
erickson [Thu, 6 Mar 2008 21:32:11 +0000 (21:32 +0000)]
added connect-only handling

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded connect/disconnect support, with onconnect callback
erickson [Thu, 6 Mar 2008 20:22:01 +0000 (20:22 +0000)]
added connect/disconnect support, with onconnect callback

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded support for ses.request(method, param1, param2, ...) style requests
erickson [Thu, 6 Mar 2008 19:32:07 +0000 (19:32 +0000)]
added support for ses.request(method, param1, param2, ...) style requests

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded support for hash-encoded json objects
erickson [Thu, 6 Mar 2008 17:28:04 +0000 (17:28 +0000)]
added support for hash-encoded json objects

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoUpdated OpenSRF Javascript client library. Currently, it only implements XMLHttpRequ...
erickson [Thu, 6 Mar 2008 17:22:21 +0000 (17:22 +0000)]
Updated OpenSRF Javascript client library.  Currently, it only implements XMLHttpRequest as
a transport layer, and, thus far, only implements the multipart/x-mixed-replace (server push)
content type, which means only Mozilla browsers are support.

Non-multipart support will be added to support all other browsers in the future -- not much
code involved there.

Most of the existing OpenSRF JS files will be deprecated after the mozilla-based jabber
handling is imported into this new lib.

Currently, all you need is opensrf.js and opensrf_xhr.js to use the lib in xmlhttprequest mode

More work to do....

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoRemove <domains> element - breaks gateway.
dbs [Thu, 6 Mar 2008 04:10:35 +0000 (04:10 +0000)]
Remove <domains> element - breaks gateway.
Clean up whitespace, add modelines, and fix typo.
Bump version of opensrf.xml to 0.0.3

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoOvercome old setuptools' inability to convert FTP listings to URLs with
dbs [Thu, 6 Mar 2008 03:02:59 +0000 (03:02 +0000)]
Overcome old setuptools' inability to convert FTP listings to URLs with
a direct URI for python-memcached

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoupdated to match new config layout
erickson [Wed, 5 Mar 2008 23:14:41 +0000 (23:14 +0000)]
updated to match new config layout

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoAdded support for multi-router registration
erickson [Wed, 5 Mar 2008 22:36:59 +0000 (22:36 +0000)]
Added support for multi-router registration
replaced unnecessary <domains><domain/></domains> with a single <domain> element in opensrf_core.xml
wrapped the top-level <router> element in a <routers> container element in opensrf_core.xml to
    support additional router configuration
Updated the python, C, and Perl to match the above changes
Gave the router the ability to launch more than one router process, based on the config
Added a transport_error flag to C session to indicate a communcation error, which will prevent
    client sessions from hanging when making bad requests

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded a ":" to the getopt "c" option so it would take a param
erickson [Wed, 5 Mar 2008 14:30:12 +0000 (14:30 +0000)]
added a ":" to the getopt "c" option so it would take a param

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoBail with a reasonable error message if OPT_CONFIG does not exist
dbs [Mon, 3 Mar 2008 13:34:25 +0000 (13:34 +0000)]
Bail with a reasonable error message if OPT_CONFIG does not exist

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoMake the path to opensrf_core.xml argument optional, with a default
dbs [Mon, 3 Mar 2008 03:56:53 +0000 (03:56 +0000)]
Make the path to opensrf_core.xml argument optional, with a default
value based on the path used to invoke

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agox.y.z version numbering seems to make setuptools happier... okay
dbs [Sat, 16 Feb 2008 18:12:57 +0000 (18:12 +0000)]
x.y.z version numbering seems to make setuptools happier... okay

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoupdated to fit new opensrf updates
erickson [Thu, 14 Feb 2008 00:15:39 +0000 (00:15 +0000)]
updated to fit new opensrf updates

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agomakeing osrfSystemCacheInit() a "public" function. pushing osrfSystemCacheInit(...
erickson [Mon, 11 Feb 2008 18:49:44 +0000 (18:49 +0000)]
makeing osrfSystemCacheInit() a "public" function.  pushing osrfSystemCacheInit() into the child_init phase to prevent shared cache handles.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agogracefully handle a null server resposne
erickson [Thu, 7 Feb 2008 20:13:44 +0000 (20:13 +0000)]
gracefully handle a null server resposne

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agofix paging for large app introspection
miker [Thu, 7 Feb 2008 18:58:50 +0000 (18:58 +0000)]
fix paging for large app introspection

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar (including commentary):
miker [Thu, 31 Jan 2008 19:46:21 +0000 (19:46 +0000)]
Patch from Scott McKellar (including commentary):

1. I added the const qualifier to the second parameter of xmlSaxAttr().

2. I moved the prototype of _xmlToJSON() from the header to the
implementation file, and made the function static.

At least in its present form, _xmlToJSON should not be part of the
public interface because it is confusing.  Sometimes it allocates a
new jsonObject, which needs to be freed, and sometimes it doesn't.

A better design would be for it to expect to receive a non-NULL pointer
to an existing jsonObject.  Since it is called in only one place
(other than a couple of recursive calls), this would be an easy
change to make.  However I left it alone -- as long as the function
is visible only from within its own source file, the potential for
confusion is limited.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Thu, 31 Jan 2008 19:39:02 +0000 (19:39 +0000)]
Patch from Scott McKellar:

1. I replaced the deprecated identifier osrf_message with osrfMessage,
except for the typedef defining the former.

2. In the header I commented out the prototypes for
osrf_message_set_request_info() and osrf_message_to_xml(), since these
functions are nowhere defined.

3. I made sure to initialize all members of a newly allocated

4. In osrf_message_deserialize(): I changed a series of ifs into a
series of else ifs, in order to avoid needless comparisons after one
comparison finds a match.

5. Also in osrf_message_deserialize(): I introduced a temporary
variable to cache the result of some calls to jsonObjectGetString(),
in order to avoid repeating the identical calls.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar to plug a memory leak in the mathbench test application
miker [Thu, 31 Jan 2008 19:32:04 +0000 (19:32 +0000)]
Patch from Scott McKellar to plug a memory leak in the mathbench test application

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar to plug a memory leak in the mathbench test application
miker [Thu, 31 Jan 2008 19:31:07 +0000 (19:31 +0000)]
Patch from Scott McKellar to plug a memory leak in the mathbench test application

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar to replace some deprecated identifiers
miker [Thu, 31 Jan 2008 19:29:08 +0000 (19:29 +0000)]
Patch from Scott McKellar to replace some deprecated identifiers

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Thu, 31 Jan 2008 19:23:27 +0000 (19:23 +0000)]
Patch from Scott McKellar:

1. In osrfSystemBootstrap(): we build an osrfStringArray of children
to spawn, and then spawn them.  However we didn't free the
osrfStringArray afterwards.  Now we do.

2. In osrfSystemBootstrapClientResc(): we were potentially leaking
the osrfStringArray arr in an early return.  I moved the early return
to a point before the allocation of the osrfStringArray and a number
of other things.  Not only does the early return not have to free
the osrfStringArray, it also doesn't have to free the other things
any more.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Thu, 31 Jan 2008 19:19:47 +0000 (19:19 +0000)]
Patch from Scott McKellar:

1. In osrf_json_gateway_method_handler(): we were leaking the
jsonObject arr.

2. Also in osrf_json_gateway_method_handler(): we were leaking session
in the case of an early exit.

3. Replaced identifiers:

   osrf_app_client_session_init   ==> osrfAppSessionClientInit
   osrf_app_session               ==> osrfAppSession (struct)
   osrf_message                   ==> osrfMessage
   osrf_message_free              ==> osrfMessageFree
   string_array                   ==> osrfStringArray
   string_array_destroy           ==> osrfStringArrayFree

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Thu, 31 Jan 2008 19:12:40 +0000 (19:12 +0000)]
Patch from Scott McKellar:

1. In send_request() we allocate a jsonObject o and then immediately
assign the resulting pointer to params.  I eliminated the rather
pointless o and allocated params directly.

2. We didn't ever free params.  Now we do.

3. I replaced two deprecated identifiers with their camel-case

   osrf_app_client_session_init   ==> osrfAppSessionClientInit
   osrf_message_free              ==> osrfMessageFree

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar to fix up some const correctness issues.
miker [Thu, 31 Jan 2008 19:09:46 +0000 (19:09 +0000)]
Patch from Scott McKellar to fix up some const correctness issues.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Thu, 31 Jan 2008 19:07:30 +0000 (19:07 +0000)]
Patch from Scott McKellar:

1. I replaced the following identifiers with their camel-case

   osrf_message             ==> osrfMessage
   osrf_message_free        ==> osrfMessageFree
   string_array             ==> osrfStringArray
   string_array_get_string  ==> osrfStringArrayGetString

2. In osrf_app_server_session_init() we were leaking session in the
case of an early return.  I stuck in a free().

3. Likewise in osrfAppSessionMakeLocaleRequest() we were leaking req
in the case of an early return.  I plugged that one too.

4. In osrfAppRequestRespondComplete() we were leaking payload in one
branch of an if/else.  I moved the osrfMessageFree() beyond both
branches so that it would be unconditional.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Thu, 31 Jan 2008 19:05:18 +0000 (19:05 +0000)]
Patch from Scott McKellar:

1. I moved the declarations of the following functions out of the
header and into the implementation file, and declared the functions
as static:

   __osrfAppFindMethod (and removed both underscores)
   __osrfAppRunSystemMethod (and removed one underscore)
   __osrfAppRegisterSysMethods (and removed one underscore)
   __osrfAppPostProcess (and removed one underscore)

2. I plugged a memory leak in osrfAppRunExitCode (we weren't freeing
the osrfHashIterator).

3. I made sure to populate all members of a new osrfMethod.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Thu, 31 Jan 2008 18:23:52 +0000 (18:23 +0000)]
Patch from Scott McKellar:

1. I renamed __osrfRouter simply to router, and made it static.  We
had one global variable and one auto variable pointing to the same
object, causing some needless juggling.  Now we have just one

2. I removed the leading underscores from __setupRouter().

3. I renamed the parameter to routerSignalHandler() from "signal"
to "signo", since "signal" is a reserved identifier.  I also added
some code to re-raise the signal caught.

[from a followup email]

> I chose instead to terminate the program by re-raising the signal.
> That way the parent process has a chance to detect that the program
> was terminated by a signal rather than by a normal return.

After posting this I realized that the router program runs as a
daemon, and its adopted parent process doesn't care whether it
terminates by a signal or by a normal return.  So there's not
much point in re-raising the signal.

It remains true that the signal handler should contrive to
terminate the program, either by exiting or by setting a flag that
the rest of the program tests.

[ The original patch, re-raising the signal, is applied. ]

4. In main() I moved two calls to free() so that they are reachable.

5. In main() I return either EXIT_SUCCESS or EXIT_FAILURE, which are
portable.  Otherwise we could find ourselves returning -1, which is
not portable.

6. In setupRouter() I arranged to free resource, and to free
tservers and tclients in the case of an early return.  I also free
router in the unlikely event that osrfRouterRun returns.

7. I reworded an error message to something that I think is more

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Thu, 31 Jan 2008 18:18:29 +0000 (18:18 +0000)]
Patch from Scott McKellar:

1. In the header: I added compilation guards.

2. In the header: I changed leading double underscores to leading
single underscores.  These identifiers don't appear elsewhere in the
code base, with either double or single underscores.

3. I moved most of the header into the implementation file.  The
headers whose prototypes I moved are now static.  Where there were
comments associated with the prototypes, I moved them to the function

4. I removed an extra leading underscore from __osrfRouterFillFDSet().

5. I replaced some deprecated identifiers with their camel-case

   osrf_message_free   ==> osrfMessageFree
   osrf_message        ==> osrfMessage

6. I added the const qualifier to several function parameters.

7. In a couple of spots we were failing to free classname buffers.
I plugged those leaks.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agocamelCasingPatch from Scott McKellar
miker [Thu, 31 Jan 2008 17:33:02 +0000 (17:33 +0000)]
camelCasingPatch from Scott McKellar

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agotry/except/finally combinations are only supported in Python 2.5. in this case,...
erickson [Wed, 30 Jan 2008 17:36:43 +0000 (17:36 +0000)]
try/except/finally combinations are only supported in Python 2.5.  in this case, the finally is not necessary. removed it

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoturn \d{1,10} into a number on the wire
miker [Wed, 30 Jan 2008 17:30:43 +0000 (17:30 +0000)]
turn \d{1,10} into a number on the wire

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoupdating legacy JSON parser to store numbers as strings
erickson [Wed, 30 Jan 2008 17:06:21 +0000 (17:06 +0000)]
updating legacy JSON parser to store numbers as strings

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoappending neglected boolean object to growing JSON object. Thanks, Scott
erickson [Tue, 29 Jan 2008 17:03:41 +0000 (17:03 +0000)]
appending neglected boolean object to growing JSON object.  Thanks, Scott

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agopython opensrf pre-forking server implementation. this component manages the
erickson [Tue, 29 Jan 2008 03:17:07 +0000 (03:17 +0000)]
python opensrf pre-forking server implementation.  this component manages the
"inbound" and drone processes for server applications.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agocreated a shallow clone method
erickson [Tue, 22 Jan 2008 19:09:37 +0000 (19:09 +0000)]
created a shallow clone method

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoSet the Makefile shell to bash via the Makefile SHELL variable
dbs [Tue, 22 Jan 2008 16:35:51 +0000 (16:35 +0000)]
Set the Makefile shell to bash via the Makefile SHELL variable

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded the ability to wait forever by passing <0 to recv. explicitly setting sender...
erickson [Sun, 20 Jan 2008 00:00:15 +0000 (00:00 +0000)]
added the ability to wait forever by passing <0 to recv.  explicitly setting sender address in messages to be correct.  added ability to create a message from raw xml

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agolibxml2 and libxslt1 Python modules are abnormal - remove them from requires list
dbs [Thu, 17 Jan 2008 16:39:23 +0000 (16:39 +0000)]
libxml2 and libxslt1 Python modules are abnormal - remove them from requires list
We'll document how to install these as system packages instead

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoAdd dnspython, libxml, and libxslt1 dependencies on behalf of pyxmpp
dbs [Wed, 16 Jan 2008 17:40:07 +0000 (17:40 +0000)]
Add dnspython, libxml, and libxslt1 dependencies on behalf of pyxmpp

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoadded the ability to use cjson for json encoding/decoding. gracefully falls back...
erickson [Wed, 16 Jan 2008 16:48:24 +0000 (16:48 +0000)]
added the ability to use cjson for json encoding/decoding.  gracefully falls back to simplejson

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoI started adding some basic bootstrap options looking ahead to server-side python.
erickson [Tue, 15 Jan 2008 23:24:31 +0000 (23:24 +0000)]
I started adding some basic bootstrap options looking ahead to server-side python.
This resulted in a small set of code cleanup including:
    move from camelCase to lower_under for method names
    move from global variables to class-level static variables
    move from global functions to class-level static functions

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoRevert Gentoo changes (sigh)
dbs [Tue, 15 Jan 2008 18:02:41 +0000 (18:02 +0000)]
Revert Gentoo changes (sigh)

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoMake cleaning in Python dir optional as well, to avoid problems with missing setuptools
dbs [Tue, 15 Jan 2008 17:50:06 +0000 (17:50 +0000)]
Make cleaning in Python dir optional as well, to avoid problems with missing setuptools

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoAdd a build flag for Python modules
dbs [Tue, 15 Jan 2008 17:42:45 +0000 (17:42 +0000)]
Add a build flag for Python modules

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoBootstrapping doesn't work as desired on systems that already have setuptools
dbs [Tue, 15 Jan 2008 17:37:11 +0000 (17:37 +0000)]
Bootstrapping doesn't work as desired on systems that already have setuptools

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoBootstrap setuptools, drop unnecessary directory metadata
dbs [Tue, 15 Jan 2008 15:51:49 +0000 (15:51 +0000)]
Bootstrap setuptools, drop unnecessary directory metadata

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoremoving old, unused code
erickson [Tue, 15 Jan 2008 14:43:40 +0000 (14:43 +0000)]
removing old, unused code

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoSwitch to setuptools to enable dependency installs as well
dbs [Tue, 15 Jan 2008 04:03:07 +0000 (04:03 +0000)]
Switch to setuptools to enable dependency installs as well

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agorepaired expire time logic to force use of the configured max if timeout is indefinit...
erickson [Mon, 7 Jan 2008 14:55:36 +0000 (14:55 +0000)]
repaired expire time logic to force use of the configured max if timeout is indefinite (0) or larger than max

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 7 Jan 2008 02:11:47 +0000 (02:11 +0000)]
Patch from Scott McKellar:

1. I moved almost everything from the header file into the
implementation file, since it isn't referenced elsewhere.  All that's
left is one function prototype and a series of nested #includes.

2. I added compilation guards to the header.

3. Except for osrf_prefork_run(), all functions are now static, as is
the child_dead variable.

4. I commented out the MAX_BUFSIZE macro, since it isn't used.

5. I removed the declaration of main(), which seemed rather pointless.

6. I added the const qualifier to the parameters of osrf_prefork_run()
and osrf_prefork_routers().

7. I made sure that all members were explicitly initialized when
creating a prefork_simple or a prefork_child.

8. I commented out both the prototype and the definition of
find_prefork_child(), since we don't call it anywhere.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 7 Jan 2008 02:08:10 +0000 (02:08 +0000)]
Patch from Scott McKellar:

1. I moved almost everything from the header into the implementation
file, since it isn't referenced elsewhere.  All that's left is one
prototype and some nested #includes.

2. I moved the nested #includes inside the compilation guard.

3. Except for osrf_stack_transport_handler(), all functions are now

4. I applied the const qualifier to the second parameter of

5. I plugged a memory leak in osrf_stack_transport_handler().  When
unable to open a session, we were returning without freeing the
input message.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoJSON to XML patches from Scott McKellar:
miker [Mon, 7 Jan 2008 02:04:54 +0000 (02:04 +0000)]
JSON to XML patches from Scott McKellar:

Guard against multiple #inclusions.

Plug a potential memory leak in the jsonObjectToXML
function.  If the input parameter was NULL we would fail to free
the growing_buffer we had just allocated.  I rearranged it to check
for NULL before allocating the growing_buffer.

Also: I added the static qualifier to the _escape_xml function, to
match the declaration at the top of the file.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoMemory leak fixes for the old-style gateway:
miker [Mon, 7 Jan 2008 02:00:25 +0000 (02:00 +0000)]
Memory leak fixes for the old-style gateway:

1. osrf_locale, allocated by either buffer_release() or strdup().

2. A series of buffers allocated by apacheGetFirstParamValue():


git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoMemory leak plugged by Scott McKellar:
miker [Mon, 7 Jan 2008 01:57:18 +0000 (01:57 +0000)]
Memory leak plugged by Scott McKellar:

In handle_request() we allocate a growing_buffer and pass the pointer
to send_request().  However we weren't freeing the growing_buffer
after the return from send_request().

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoTwo patch sets from Scott McKellar
miker [Mon, 7 Jan 2008 01:55:25 +0000 (01:55 +0000)]
Two patch sets from Scott McKellar


from the header into the implementation file.  No other source files
reference them, nor should they.

2. I moved the OSRF_LIST_MAX_SIZE macro into the implementation file
as well, and then commented it out.  It is nowhere referenced, but
out of caution I preserved it like a fly in amber.

3. I removed a leading underscore from each of the struct names
__osrfListStruct and __osrfListIteratorStruct.

4. I removed some obsolete comment text concerning osrfNewList().

5. I deleted the declaration for __osrfListSetSize(), which is
nowhere defined.

6. I made sure to explicitly initialize all struct members.

7. When allocating pointer arrays, I explicitly initialize all the
pointers to NULL.

8. I rewrote osrfNewList() as a thin wrapper for osrfNewListSize(),
to eliminate some duplication of code.


These patches eliminate the following identifiers, which have all been
replaced by their camel-case equivalents:


git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Mon, 7 Jan 2008 01:46:42 +0000 (01:46 +0000)]
Patch from Scott McKellar:

1. Move several internal details from the header to the implementation

   The declaration of the osrfHashNode struct
   The declarations of the osrfNewHashNode and osrfHashNodeFree
       functions (which are now static)

2. Remove a leading underscore from each of the struct tags
__osrfHashStruct and __osrfHashIteratorStruct;

3. Explicitly initialize all struct members.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoEnable Python build with regular user to avoid perm problems at clean time.
dbs [Mon, 7 Jan 2008 00:37:13 +0000 (00:37 +0000)]
Enable Python build with regular user to avoid perm problems at clean time.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agousing new C-based JSON parser: JSON::XS - this new code wraps the to/from JSON calls...
erickson [Sun, 6 Jan 2008 21:12:09 +0000 (21:12 +0000)]
using new C-based JSON parser: JSON::XS - this new code wraps the to/from JSON calls with opensrf class management

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoproviding option to connect to memcache at general connect time
erickson [Sun, 6 Jan 2008 20:24:43 +0000 (20:24 +0000)]
providing option to connect to memcache at general connect time

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agomade exceptions a litte more generic, passing msg to superclass for networexception
erickson [Sun, 6 Jan 2008 20:22:57 +0000 (20:22 +0000)]
made exceptions a litte more generic, passing msg to superclass for networexception

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Sat, 5 Jan 2008 19:07:02 +0000 (19:07 +0000)]
Patch from Scott McKellar:

These patches are the culmination of several postings on this subject.
The overall effect is to store numbers in jsonObjects as strings,
rather than as doubles, in order to avoid needless loss of precision
in translating back and forth between text and floating point

I shall not repeat the details outlined in previous posts, but rather
focus on what's new:

1. A new extern function jsonNewNumberStringObject constructs a
JSON_NUMBER from a character string.  If the string is not numeric
according to JSON rules, the function returns NULL.

2. A new extern function jsonScrubNumber accepts a character string
and reformats it, if possible, into a numeric string that is valid
according to JSON rules.  For example, it transforms "  +00.42"
into "0.42".  The transformed string is returned as a char* that
the caller is responsible for freeing.

jsonScrubNumber performs this transformation by manipulating text,
not by passing the value through a double.  Therefore it can handle
numbers that would be too long, too large, or too small for strtod()
and its kindred to handle.

It accepts leading white space and scientific notation, but not
trailing white space, hex, or octal.

If the input string is not numeric, jsonScrubNumber returns NULL.

3. The doubleToString function now translates the incoming double
to a character string with up to 30 decimal digits of precision.
That should be enough to minimize the impact on existing code,
depending of course on how faithfully snprintf() does the formatting.

4. In osrf_json.h: I changed the signature of the next-to-last
function pointer in a jsonParserHandler, so that it accepts a
character pointer instead of a double.  Likewise for the corresponding
declaration of _jsonHandleNumber in osrf_json_utils.h.

5. In osrf_json_parser.c: I construct a JSON_NUMBER from the input
character string without passing it through a double.  If the input
character string is not valid according to JSON rules, I try to use
the new jsonScrubNumber() to normalize the formatting so that JSON
can accept it.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoremoved assumption that settings values would be numbers. cleaned up the code some...
erickson [Thu, 3 Jan 2008 22:28:52 +0000 (22:28 +0000)]
removed assumption that settings values would be numbers.  cleaned up the code some to make it more readable

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agochanged str to msg to prevent clobbering. changed repr call to unicode, which seems...
erickson [Wed, 2 Jan 2008 18:53:30 +0000 (18:53 +0000)]
changed str to msg to prevent clobbering.  changed repr call to unicode, which seems more appropriate for human-readable error message

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Tue, 1 Jan 2008 02:00:38 +0000 (02:00 +0000)]
Patch from Scott McKellar:

1. Makes sure that all members of OsrfChatServer and OsrfChatNode are
explicitly initialized;

2. Plugs several actual or potential memory leaks.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Tue, 1 Jan 2008 01:56:28 +0000 (01:56 +0000)]
Patch from Scott McKellar:

1. Plugs a memory leak in file_to_string().  If we failed to open the
file, we were returning without freeing the growing_buffer that held
the file name.

2. Replaces a couple of calls to buffer_data() with calls to

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar:
miker [Tue, 1 Jan 2008 01:52:44 +0000 (01:52 +0000)]
Patch from Scott McKellar:

1. Added the const qualifier in various places.

2. Eliminated some unnecessary calls to strlen(), where they were
used merely to determine whether a string was empty.

3. Ensured that all members of a new transport_message are
explicitly populated.

4. Plugged a memory leak in the case where strdup() fails.

5. Eliminated some unhelpful casts of malloc'd pointers.

6. Added some protective tests for NULL pointer parameters.

7. In several spots I replaced numeric literals with character
literals, both to make the code more readable and to avoid a needless
dependence on ASCII.

8. Rewrote the jid_get_resource function to avoid repeatedly
overwriting the same buffer.

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar; use camelCase instead of under_score function names
miker [Tue, 1 Jan 2008 01:42:22 +0000 (01:42 +0000)]
Patch from Scott McKellar; use camelCase instead of under_score function names

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar; use camelCase instead of under_score function names
miker [Tue, 1 Jan 2008 01:41:31 +0000 (01:41 +0000)]
Patch from Scott McKellar; use camelCase instead of under_score function names

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar; use camelCase instead of under_score function names
miker [Tue, 1 Jan 2008 01:40:30 +0000 (01:40 +0000)]
Patch from Scott McKellar; use camelCase instead of under_score function names

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865

12 years agoPatch from Scott McKellar; use camelCase instead of under_score function names
miker [Tue, 1 Jan 2008 01:38:58 +0000 (01:38 +0000)]
Patch from Scott McKellar; use camelCase instead of under_score function names

git-svn-id: svn:// 9efc2488-bf62-4759-914b-345cdb29e865