miker [Mon, 25 Jun 2007 03:06:56 +0000 (03:06 +0000)]
Patch from Scott McKellar to improve default logging:
1. In log.h I added another macro OSRF_LOG_TYPE_STDERR by which the
application can specifically request logging to standard error.
2. In log.c I initialze _osrfLogType to OSRF_LOG_TYPE_STDERR so that
the application can issue a log message even if it hasn't called
osrfLogInit() yet.
3. I added the const qualifier to the parameters of the functions
_osrfLogToFile() and _osrfLogSetXid().
4. In osrfLogCleanup() I set _osrfLogAppname and _osrfLogFile to
NULL after freeing them. Otherwise the application could cause
needless mischief by calling this function twice.
5. Also in osrfLogCleanup() I set _osrfLogType back to the default
OSRF_LOG_TYPE_STDERR so that the application can still issue a
message after calling osrfLogCleanup().
6. I rewrote osrfLogSetType() to use switch/case instead of an "if".
Now that we have three valid values to check instead of two, a
switch/case is a little tidier. Also the default branch applies
the default log type OSRF_LOG_TYPE_STDERR.
7. _osrfLogDetail() had a local variable named "l" (lower case L).
I renamed it to "label" because "l" looks too much like a digit.
8.Also in _osrfLogDetail(): I added a branch to write a message to
stderr when _osrfLogType is OSRF_LOG_TYPE_STDERR.
9. The existing _osrfLogToFile function sizes and declares a buffer
named "buf", fills it with zeros, and then doesn't do anything with
it. This buffer is probably a relic of some earlier version. I
eliminated it.
10. A few lines thereafter, I eliminated a useless call to bzero().
11. The call to strftime() contained a hard-coded buffer size. I
changed it to use the sizeof operator, so that the buffer size is
defined in only one place.
12. If we can't open the log file, we write a message to stderr.
In this message I changed "file" to "log file" to make the meaning
more clear to a benighted and panicky user.
13. If after writing the message we can't close the file, the
existing code logs an error message by calling osrfLogWarning().
However in this circumstance this latter message will probably meet
the same fate, and no one will ever see it. I changed the code so
as to write this message to stderr.
erickson [Thu, 21 Jun 2007 16:19:20 +0000 (16:19 +0000)]
Merged libopensrf source directories (libtransport, libstack, and utils) into a single libopensrf directory
Moved opensrf headers to trunk/include/opensrf
Moved objson headers to trunk/include/objson
Updated #include's throughout to be fully qualified. e.g. <opensrf/utils.h>, <objson/object.h>
Removed old, unused trunk/src/xinclude code
Cleaned up Makefiles to support new directory layout
miker [Wed, 20 Jun 2007 03:49:48 +0000 (03:49 +0000)]
Added osrfLogGetLevel method, then applied
partial patch from Scott McKellar:
Whenever a declared identifier had two leading underscores, I
removed the first one, except for a few cases where I removed the
second one and kept the first one.
I moved the prototypes for the following functions to log.c, and
declared them static:
miker [Sat, 16 Jun 2007 23:58:35 +0000 (23:58 +0000)]
Patch from Scott McKellar to add stderr logging when config (and thus configured logging) is unavailable:
If osrfConfigInit() is unable to load the configuration file,
it issues error messages to the log.
Unfortunately, if we can't load the configuration file, we don't know
where the log file is. The usual result is that the messages don't
go anywhere. At best, depending on some convoluted details that
aren't worth going into here, the messages will go to an obscure
system-wide syslog file that only a hardened system administrator
could love.
In this patch I send similar messages to standard error, so that
someone can see them. It might make sense to delete the calls
to osrfLogWarning(), but I left them alone.
erickson [Fri, 15 Jun 2007 03:18:51 +0000 (03:18 +0000)]
Cleaned up the network hint / object registration code in net_obj
Added object2XML function for posting XML to the opensrf gateway
updated the gateway to deal with the new object API
erickson [Thu, 14 Jun 2007 16:03:57 +0000 (16:03 +0000)]
Added a new XML-2-JSON utility for converting XMLized OpenSRF objects to their internal JSON representations
Added a new gateway param "input_format" to define the param format.
Options are "json" and "xml".
Unless overridden, input_format will match format
miker [Tue, 12 Jun 2007 02:52:42 +0000 (02:52 +0000)]
Patch from Dan Scott to fix up the OpenSRF build process in the new SVN repo:
OpenSRF-svn-build.patch: this modifies the objson headers to specify
that "utils.h" is actually found in "opensrf/utils.h". I beleive the
ILS build was failing with the unqualified include because it didn't
have access to the utils.h file that used to be kept around in a
common TMP directory when OpenSRF and ILS were built simultaneously.
miker [Tue, 12 Jun 2007 01:10:05 +0000 (01:10 +0000)]
Patch from Scott McKellar with minor adjustments:
1. In an earlier patch to osrf_settings_host_value_object(), we
contrived to abort the program deliberately instead of crashing with
a segmentation violation. The current patch applies the same
treatment to the similar function osrf_settings_host_value(),
although I don't know that anyone has ever reported a problem at
this spot. I rearranged the error message a bit so that it would
be distinct from the other one.
2. If the config pointer is null, it's because osrf_settings_retrieve()
was unable to populate it, or was never called. There are two ways
it might fail: it might not get an osrf_message from
osrf_app_session_request_recv(), or the osrf_message it gets might
not have the _result_content member populated. I added a couple of
log messages to distinguish between these possibilities. Maybe they
will make diagnosis easier.
3. The latter change also plugs a small memory leak. If we get an
osrf_message but it has no _result_content, the present code neglects
to free the osrf_message.
miker [Tue, 12 Jun 2007 01:08:25 +0000 (01:08 +0000)]
Patch from Scott McKellar:
1. I declared several functions as static, and moved their prototypes
from the header file to the implementation file. In each case I
verified that nothing else in the code base calls it.
2. I removed the socket_send_nowait prototype from the header, and
commented it out in the implementation file. I was tempted to
eliminate it entirely, but stayed my hand. It is a trivial wrapper
for _socket_send(), and nothing calls it.
3. Nothing calls several other functions either. However unlike
socket_send_nowait() they are non-trivial functions, and they appear
to be intended for external linkage, so I left them alone for
potential future use.
4. The identifier _socket_print_list is reserved for local scope,
and should not have external linkage, because it starts with an
underscore followed by a lower case letter. I may submit a patch to
rename it some day if I ever get around to it, but that will require
a change in socket_test.c, which calls it.
5. I moved the definition of the RBUFSIZE macro from the header file
into the implmentation file. It is an internal detail that no
other translation unit should know or care about.
miker [Tue, 12 Jun 2007 01:05:53 +0000 (01:05 +0000)]
Patch from Scott McKellar:
1. I made __osrfChatXMLErrorOcurred and __osrfChatClientSentDisconnect
static, and removed the leading underscores from their names. No other
source files refer to them.
2. In osrfNewChatServer() I explicitly initialize the port member to
zero -- which is already happening implicitly due to the memset() in
safe_malloc().
3. Also in osrfNewChatServer(): the existing code populates the secret
member only if the secret parameter is not NULL, and leaves it
uninitialized otherwise. However if the secret parameter were NULL
we would have already performed an early exit. I populate the secret
member unconditionally, just as we do with the domain member. I also
moved this assignment up with the other assignments, for a more
readable flow.
4. In osrfChatServerFree(), the existing code leaves several memory
references dangling, without freeing them. I added code to free the
domain member, the deadNodes member, and finally the osrfChatServer
itself.
miker [Tue, 29 May 2007 02:43:20 +0000 (02:43 +0000)]
Patch from Dan Scott; adds -rpath=$(LIBDIR) to the default LDFLAGS for
OpenSRF, obviating the need to set up non-standard system search paths
for any libs that OpenSRF loads that either don't have a lib prefix
or live outside the normal system library paths.
miker [Mon, 28 May 2007 20:12:23 +0000 (20:12 +0000)]
Patch from Scott McKellar; reasonable and non-intrusive diagnostic message in
the case that we've been given on port or unix socket path to connect over.
miker [Mon, 28 May 2007 20:08:47 +0000 (20:08 +0000)]
Patch from Scott McKellar; allows the compiler to warn us of missing casts
coming from undefined safe_malloc()s, NULL-initialize pointers (\0 != NULL).
miker [Mon, 28 May 2007 19:57:19 +0000 (19:57 +0000)]
Several combined cleanup patches from Scott McKellar:
* remove leading underscores from static vars and functions
* make static functions, well, static
* tighten up the definition of funcs that take 0 params
miker [Sun, 27 May 2007 00:49:10 +0000 (00:49 +0000)]
http://list.georgialibraries.org/pipermail/open-ils-dev/2007-May/001092.html
Patch from Scott McKellar to:
* Make default config object pointer static (module local)
* Clean up variable name to remove leading underscores
* Remove think-o which would deallocate the default config when
loading any other
* Fix error log message
miker [Mon, 21 May 2007 02:31:52 +0000 (02:31 +0000)]
strndup() and strnlen() implementations from Jeroen Ruigrok van der Werven
See bug #551 for original details -- http://open-ils.org/cgi-bin/bugzilla/show_bug.cgi?id=551
erickson [Fri, 18 May 2007 16:57:56 +0000 (16:57 +0000)]
returning OK status in respond method, instead of no status at all. most code uses respond_complete, which is why this has not been an issue in the past. writing new client libs exposed it, though
Exiting with a usable error message rather than segfaulting
- patch provided by Scott McKellar
- http://list.georgialibraries.org/pipermail/open-ils-dev/2007-April/000727.html
Avoiding memory leaks in string opperations
- patch provided by Scott McKellar
- http://list.georgialibraries.org/pipermail/open-ils-dev/2007-April/000724.html