qb_ipcs_dispatch_connection_request is a callback function registered with
mainloop, or whatever other looping thread implementation is in use. When
this callback is registered, a reference of the connection object is given
to the mainloop thread. If this callback ever returns something none zero
the callback (and corresponding fd) is unregistered from the loop automatically,
so we must decrement the reference in this instance.
Since unregistering this callback from mainloop guarantees a disconnect
simply because requests on the fd are no longer processed, it is best
that we completely disconnect the connection (which will handle the unref)
when this callback returns an error... Otherwise since the fd is unregistered
from the mainloop thread, it may not be possible to detect a disconnect
in the future.
In the future, if something changes in the file header we can
increment the version and split up the parsing into separate functions
for backwards compatibility.
The ringbuffer protocol uses the chunk magic number to indicate to the
other side what state a chunk is in. It's therefore important to use
strongly ordered memory writes to make sure that neither the compiler
nor the CPU change the apparent order of the writes, since that would
result in corrupted messages.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This is because the connection functions use the c->service pointer
and this needs to be mirrored in the reference counting.
The service can only be free'd when all connections are destroyed
and the user as unreferenced all previously referenced connections
and the service.
Fixes#62
Thanks to Jan Friesse for the reproducer
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
callsites originate from the assumption that the function/filename/format
are all statically allocated. When moving to dynamic callsite we kept
this assumption. But people are now passing in function/file names that
later get free'd. So we need to make sure that they stay persistant by
allocating them ourselves.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
don't block completely on the sem_wait(), but chop the waits
into 1 sec blocks so the destroy can have an opertunity to complete.
fixes bug #55
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Seperate into a setup file and a socket backend file, it was getting messy
and confusing. Also preparing for using DGRAM sockets.
This should not result in any logical changes.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Just add a rwlock around the usage.
Move qb_log_format_set() to log_format.c to make this easier.
Fixes#45
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
If free'ing the iterator before getting to the last
node make sure we de-ref the current node. Else we
will not be able to delete the node.
fixes#44
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
So just manually call us_ready (poll) with a timeout of 50ms
to prevent cpu spin.
Also update qb_ipc_us_recv() to be simerlar.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This is a test to make sure that there is actually enough memory
to back the requested shared memory.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>