utils proto: Added utility functions for protocol handling.
So far, added functions to send data to an open file descriptor and use that
in the frontend code.
So far, added functions to send data to an open file descriptor and use that
in the frontend code.
Merged branch 'master' of git://git.tokkee.org/sysdb.
Conflicts:
t/Makefile.am
t/libsysdb_test.c
t/libsysdb_test.h
Conflicts:
t/Makefile.am
t/libsysdb_test.c
t/libsysdb_test.h
.gitignore: Added check test logs.
t/: Added initial tests for core/object.
object: Be more specific about requirements for the 'destroy' callback.
object: Ensure that a type's destroy callback is called if init fails.
Else, failed init may leak memory.
Else, failed init may leak memory.
frontend: Unified error reporting to the client.
Keep track of the latest error in a connection object and report that back to
the client in case a command handler failed.
Keep track of the latest error in a connection object and report that back to
the client in case a command handler failed.
store: Let tojson() embed errors into JSON rather than aborting.
Renamed sdb_session_start() to sdb_fe_session_start().
frontend: Added a simple 'LIST' command.
This command sends a JSON representation of the whole store to the client.
This command sends a JSON representation of the whole store to the client.
store: Replaced store_dump() with store_tojson().
The new function serializes the store as JSON and writes the result to a
string buffer.
The new function serializes the store as JSON and writes the result to a
string buffer.
strbuf test: Further extended the incremental append test.
utils strbuf: Handle nul-byte correctly.
A corner-case was not handled correctly before: when writing just enough
characters to the buffer that it would then be full, a resize was attempted
without changing the size of the buffer, leading to an endless loop in
vappend(). This was caused by not taking into account the space required for
the trailing nul-byte.
A test-case which exposes this problem has also been added.
A corner-case was not handled correctly before: when writing just enough
characters to the buffer that it would then be full, a resize was attempted
without changing the size of the buffer, leading to an endless loop in
vappend(). This was caused by not taking into account the space required for
the trailing nul-byte.
A test-case which exposes this problem has also been added.
src/Makefile: Install all public header files.
frontend: Moved all connection handling operations into connection.c.
connection_obj_t was merged into sdb_conn_t which now inherits from
sdb_object_t. The connection object is now private to the library and defined
in the new header file connection-private.h.
connection_obj_t was merged into sdb_conn_t which now inherits from
sdb_object_t. The connection object is now private to the library and defined
in the new header file connection-private.h.
frontend: Report back invalid commands.
frontend: Handle STARTUP and PING commands.
Implemented an initial, trivial "framework" for session handling /
authentication. Simply send back OK status for now.
Fixed preconditions for initialization and handling of commands.
Implemented an initial, trivial "framework" for session handling /
authentication. Simply send back OK status for now.
Fixed preconditions for initialization and handling of commands.
frontend: Moved connection init/close to connection.c.
frontend/sock: Fixed an info message.
;-)
;-)
frontend/connection: Reset state after handling a command.
frontend/connection: Try to handle as much as possible in read().
Else, we might have to wait for more data before being able to process a
command.
Else, we might have to wait for more data before being able to process a
command.
frontend: Added module for generic connection handling.
Merged branch 'master' of git://git.tokkee.org/sysdb.
socket frontend: Notify about incomplete commands before closing connections.
utils strbuf: Advance buffer position in sdb_strbuf_read().
socket frontend: Read incoming commands into a buffer.
Handle commands once all of them has been read. Give preference to reading
data over handling a command in order not to block clients or exhaust
operating system buffers.
Handle commands once all of them has been read. Give preference to reading
data over handling a command in order not to block clients or exhaust
operating system buffers.
strbuf_test: Added some NULL tests.
These are mainly to check that the functions do no segfault but report an
error.
These are mainly to check that the functions do no segfault but report an
error.
strbuf_test: Added tests for len / nil-termination after skip().
utils strbuf: Added sdb_strbuf_skip().
This function may be used to remove bytes and the beginning of the buffer.
This function may be used to remove bytes and the beginning of the buffer.
socket frontend: Merged connection_obj_t and connection_t.
There's no reason for two separate structs.
There's no reason for two separate structs.
utils strbuf: Added sdb_strbuf_read().
This function may be used to read from an open file into the buffer.
This function may be used to read from an open file into the buffer.
utils strbuf: Added memcpy and memappend functions.
These functions may be used to write arbitrary data to a string buffer.
These functions may be used to write arbitrary data to a string buffer.
socket frontend: Cleaned up main handler loop a bit.
socket frontend: Try to reopen a connection if it has been closed.
socket frontend: Close sockets on error as well.
socket frontend: Close listening sockets before returning.
Also, cleaned up listener handling a bit.
Also, cleaned up listener handling a bit.
socket frontend: Disallow duplicate listen_and_serve() calls.
… and fixed a memory leak.
… and fixed a memory leak.
socket frontend: Don't use UTF-8 in comments ;-)
socket frontend: Let handler read from open connection.
Close the connection on EOF and pass back the connection to the main loop in
case no data is currently available (read() would block).
Close the connection on EOF and pass back the connection to the main loop in
case no data is currently available (read() would block).
socket frontend: Pass socket object to handler threads.
This will allow them to pass back connections to the main loop.
This will allow them to pass back connections to the main loop.
socket frontend: Renamed accept_connection → connection_accept.
socket frontend: Use nonblocking I/O for open connections.
socket frontend: Split connection accepting into its own function.
socket frontend: Manage open connections in listen_and_serve().
For that purpose, added a new object data type wrapping a connection. All open
connections are managed in a linked-link in the socket object. The main loop
now also waits data to be available on an open connection and then passed on
the connection object to the connection handler thread which is then supposed
to handle requests (not implemented yet).
For that purpose, added a new object data type wrapping a connection. All open
connections are managed in a linked-link in the socket object. The main loop
now also waits data to be available on an open connection and then passed on
the connection object to the connection handler thread which is then supposed
to handle requests (not implemented yet).
channel_test: Updated timeout check according to latest changes.
I.e. check errno rather than the return value.
I.e. check errno rather than the return value.
utils llist: Added sdb_llist_iter_remove_current().
This function may be used to remove the current (the one returned by the last
sdb_llist_iter_get_next() call) iterator value from the list.
Note, that this function is not safe if another iterator is used in parallel
at the same time.
This function may be used to remove the current (the one returned by the last
sdb_llist_iter_get_next() call) iterator value from the list.
Note, that this function is not safe if another iterator is used in parallel
at the same time.
Made log prefixes slightly more generic.
Changed "plugin" to "core" and "sock" to "frontend". Those names better
identify the context in which the error happened.
Changed "plugin" to "core" and "sock" to "frontend". Those names better
identify the context in which the error happened.
daemon: Terminate backend thread after frontends have stopped.
daemon: Exit if adding a listener fails.
socket frontend: Improved error reporting.
daemon: Added "Listen" config option.
The main thread listens on all configured addresses and serves requests
through the frontend socket module. The backend collector loop now runs in its
own background thread.
The main thread listens on all configured addresses and serves requests
through the frontend socket module. The backend collector loop now runs in its
own background thread.
frontend: Use channel shutdown to synchronize handler thread shutdown.
This allows the handler to fully control the shutdown procedure.
pthread_cancel did not play well with pthread_cond_*wait in multiple threads
and the respective locked mutex.
This allows the handler to fully control the shutdown procedure.
pthread_cancel did not play well with pthread_cond_*wait in multiple threads
and the respective locked mutex.
utils channel: Added sdb_channel_shutdown().
This function initiates a shutdown of the channel, forbidding any subsequent
writes. However, readers are still able to empty the buffer. Then, EBADF will
be returned through errno. This allows for graceful shutdowns.
This function initiates a shutdown of the channel, forbidding any subsequent
writes. However, readers are still able to empty the buffer. Then, EBADF will
be returned through errno. This allows for graceful shutdowns.
utils channel: Normalize time before passing it to phtread_cond_timedwait.
utils channel: Unlock mutex before returning on error.
utils channel: Update timeout in channel_select when needed.
utils channel: Let channel_select() set errno.
utils channel: Changed abstime argument to a timeout.
frontend/sock: Added loop control to the socket handler.
Added framework for frontend connection handling.
frontend/sock supports UNIX domain sockets for now. It doesn't do much expect
for managing listening sockets and accepting connections on them which are
then handled in the background. So far, each connection is closed right away.
frontend/sock supports UNIX domain sockets for now. It doesn't do much expect
for managing listening sockets and accepting connections on them which are
then handled in the background. So far, each connection is closed right away.
t/utils/channel_test: Added a test-case for sdb_channel_select().
utils channel: Added sdb_channel_select().
This function behaves similar to select(2) providing to passively block on a
channel operation until it becomes ready for reading and / or writing.
Optionally, a deadline may be specified.
This function behaves similar to select(2) providing to passively block on a
channel operation until it becomes ready for reading and / or writing.
Optionally, a deadline may be specified.
utils/channel: Use a mutex instead of a rwlock.
All access to the channel needs to be fully synchronized.
All access to the channel needs to be fully synchronized.
t/utils/channel_test: Added some more write/read tests.
t/: Added tests for the channel implementation.
utils/channel: Added an asynchronous I/O multiplexer.
A channel is a buffered pipe supporting multiple parallel readers and writers.
A channel is a buffered pipe supporting multiple parallel readers and writers.
configure: Don't fail if CHECK is not available.
strbuf.h: Include unistd.h.
Required for ssize_t on GCC 4.4.
Required for ssize_t on GCC 4.4.
store: Make sure not to store duplicate host entries.
daemon: Treat parser errors different from daemon/libsysdb errors.
plugin: Unregister all callbacks if module/plugin init failed.
utils llist: Fixed a segfault in functions doing lookups.
utils llist: Made lookup's user-data a constant pointer.
utils llist: Added sdb_llist_remove().
utils llist: Updated documentation.
utils llist: Added lookup callback type to be used for llist_search.
Lookups should be more flexible than comparing two objects.
Lookups should be more flexible than comparing two objects.
utils llist: Added sdb_llist_cmp_cb type.
This is to make sure that comparators always use the same signature.
This is to make sure that comparators always use the same signature.
plugin: Removed sdb_ prefix from private functions.
plugin: Store real plugin name and filename in the context.
plugin: Store plugin info attributes in the plugin context.
plugin: Manage all context information in the core.
Store the new dynamic context in callbacks. The daemon may no longer set the
context before loading a plugin. Instead, sdb_plugin_load now accepts a second
parameter specifying the public context attributes.
Store the new dynamic context in callbacks. The daemon may no longer set the
context before loading a plugin. Instead, sdb_plugin_load now accepts a second
parameter specifying the public context attributes.
plugin: Made plugin context a dynamic object.
A custom type is used for that. The previous context type is used as a public
member of the new internal type. Thus, the external interface does not change.
A custom type is used for that. The previous context type is used as a public
member of the new internal type. Thus, the external interface does not change.
plugin: Dynamically allocate plugin info attributes.
This will allow to keep the information around forever.
This will allow to keep the information around forever.
unit tests: Added basic tests for unixsock utils; mocking libc I/O functions.
GNU libc's fopencookie is used to mock fdopen() and socket handling. This
allows to mock a UNIX socket.
GNU libc's fopencookie is used to mock fdopen() and socket handling. This
allows to mock a UNIX socket.
utils unixsock: Explicitely enable line-buffering.
The module is based on that, so say it explicitely.
The module is based on that, so say it explicitely.
t/utils/strbuf_test: Added lists of golden data for various checks.
This makes it much easier to add more checks for particular functions.
This makes it much easier to add more checks for particular functions.
sysdb.h.in: Reintroduced SDB_STATIC_ARRAY_LEN().
Previously only added to the auto-generated sysdb.h :-/ D'oh!
Previously only added to the auto-generated sysdb.h :-/ D'oh!
t/: Added unit tests for the string buffer utilities.
utils strbuf: Fixed a wrong assertion.
utils strbuf: Allow the initial size to be zero.
t/utils/: Name test-cases after the tested function.
This might make it possible to do coverage tests.
This might make it possible to do coverage tests.
t/utils/dbi_test: Added test queries covering 2-5 columns.
t/utils/dbi_test: Fixed further indexing.
t/utils/dbi_test: Fixed indexing into the golden_data array.
t/utils/dbi_test: Added missing cases in dbi_result_get_field_length_idx().
t/utils/dbi_test: Verify the received data.
t/utils/dbi_test: Added mock queries covering various corner cases.
t/utils/dbi_test: Mock some actual query results; added simple query.
The unit-test now supports mocking arbitrary query results. For that,
appropriate mocks for the dbi_result_get*() functions have been added.
The test now executes a simple query returning one column of data.
The unit-test now supports mocking arbitrary query results. For that,
appropriate mocks for the dbi_result_get*() functions have been added.
The test now executes a simple query returning one column of data.
t/libsysdb_test: Use a list of test-suite creators.
… rather than adding a new block for each new test-suite.
… rather than adding a new block for each new test-suite.
t/utils/dbi_test: Added a simple test-case for query execution.
Added simple mocks for query and result handling.
Added simple mocks for query and result handling.