Commit Graph

91 Commits

Author SHA1 Message Date
Michael Chapman
fad9ce01a0 ringbuffer: fix size in qb_rb_create_from_file()
qb_rb_open() expects the size field to represent the maximum chunk size.
It adds QB_RB_CHUNK_MARGIN + 1 and rounds up to the page size to
determine the ringbuffer's total size. When creating a ringbuffer from a
file we must compensate by subtracting this amount from the file's size.
2014-06-05 14:36:56 +10:00
Michael Chapman
edd2eec16c ringbuffer: fix qb_rb_open_2() debug format string
qb_log_target_formats() does not support formatting size_t values with
%zd.  Use %ld to format them as long integers instead.
2014-06-05 14:36:43 +10:00
David Vossel
00082df49f Low: blackbox: Abort blackbox logging on ringbuffer overwrite reclaim error 2013-10-08 21:59:59 -05:00
David Vossel
47c690dbbc Low: ringbuffer: Abort during chunk reclaim if OVERWRITE flag is set and reclaim fails. 2013-10-03 20:40:12 -05:00
David Vossel
9102c8d956 Fixes double fd close 2013-07-22 16:54:52 -05:00
David Vossel
bde8496352 High: ringbuffer: Make max_size of ringbuffer accurate so shm ipc max msg size value is honored 2013-07-18 22:01:29 -05:00
David Vossel
a2bdeed3cc Fix: ringbuffer: Add file header version field and detect reading corrupted blackbox files using hash value
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.
2013-06-27 19:32:05 -05:00
Angus Salkeld
67dc29f48d Use the new atomic ops in the ringbuffer
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2013-05-13 10:15:55 +10:00
Jeremy Fitzhardinge
9b3be0b450 ringbuffer: use atomic ops on ringbuffer chunk magic
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>
2013-04-24 11:57:49 +10:00
Andrew Beekhof
f16dca6df9 Indicate when/why qb_rb_force_close() fails to remove share memory files 2013-04-11 13:00:12 +10:00
Angus Salkeld
7667536626 Deal better with corrupt blackbox files.
fixes #59
Thanks to Jan Friesse for the reproducer.
https://github.com/jfriesse/csts/blob/master/tests/fplay-segfault.sh

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2013-04-02 13:52:57 +11:00
Angus Salkeld
6ba054713e RB: make the "sem" abstraction into a notifier
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2013-02-18 23:25:10 +11:00
Angus Salkeld
aedcb97690 Make sure atomic's are initialized (for non-gcc atomic).
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-09-11 14:42:04 +10:00
Angus Salkeld
d92bfa2b0e openbsd doesn't have EBADMSG
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-08-29 22:30:58 +10:00
Jeremy Fitzhardinge
4a1e24ee3e Don't free rb->shared_hdr in qb_rb_create_from_file()
Since qb_rb_close() frees it by munmapping it.
2012-08-23 10:14:11 -07:00
Angus Salkeld
e5be0396a7 RB: set the new read pointer after clearing the header.
This is to prevent a situation where a fast writer will
write their new chunk between setting the new read pointer
and clearing the header.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-07-17 21:18:47 +10:00
Angus Salkeld
3feb3b6b8f RB: improve the debug print outs
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-07-17 20:45:29 +10:00
Angus Salkeld
b9a992a5d3 RB: be more explicit about the word alignment
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-07-17 19:37:52 +10:00
Angus Salkeld
15d0291a8a RB: cleanup the macros for wrapping the index
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-07-17 12:38:22 +10:00
Angus Salkeld
6e1d9054c3 RB: use sem_getvalue as a tie breaker when read_pt == write_pt
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-07-17 12:38:22 +10:00
Angus Salkeld
bdc63cdf1a RB: if read or peek don't get the message then re-post to the semaphore
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-07-17 12:38:22 +10:00
Angus Salkeld
121abe3dbe RB: use internal reclaim function
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-07-17 12:22:26 +10:00
Angus Salkeld
22569f51ba Add user control of the permissions that are set on the shared mem files
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-06-13 08:21:09 +10:00
Angus Salkeld
3369581066 RB: use the same mechanism in reclaim as read/peek to detect end-of-ring
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-06-07 12:02:32 +10:00
Angus Salkeld
85b39906a9 RB: fix compiler warning.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-05-28 19:10:13 +10:00
Andrew Beekhof
77fa3650dd RB: Read the file size into an initialized variable of the correct size 2012-05-28 12:25:10 +10:00
Angus Salkeld
e0bc3a15ce RB: to be safer save the read and write pointers at the top of the blackbox
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-05-25 14:01:19 +10:00
Angus Salkeld
a8405ab06d blackbox: fix the print_from_file()
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-05-24 19:22:55 +10:00
Angus Salkeld
4fdabe5bed RB: add an option to not use any semaphores
(brought over from the "speed" branch)

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-05-24 19:16:59 +10:00
Angus Salkeld
3f4a175312 IPC: make it possible for a root client to talk to a non-root server.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-04-30 08:25:57 +10:00
Angus Salkeld
2ae58d2472 RB: fix test failure on ppc
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-03-07 11:37:12 +11:00
Angus Salkeld
9027c3531b RB: change the name of the size to word_size to be more clear
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-03-07 10:34:19 +11:00
Angus Salkeld
2a0cdd8f5f RB: add a debug message if trying to read a message of the wrong size
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-14 16:43:50 +11:00
Angus Salkeld
2b2dfd5d2c RB: use the proper struct not the typedef in the implementation.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-08 22:00:50 +11:00
Angus Salkeld
dff3ff4afe RB: Fix potential mem leak
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-08 22:00:50 +11:00
Angus Salkeld
7a6382f0b6 Use safer versions of string functions (strcpy -> strlcpy)
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-08 22:00:49 +11:00
Angus Salkeld
477fac4e01 IPC: fix resource cleanup if the server dies
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-01-12 15:09:58 +11:00
Angus Salkeld
ab3dc60f7f Merge some portability changes from the mingw branch
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-12-21 14:23:43 +11:00
Angus Salkeld
ef77398738 Fix errors found by api-sanity-autotest
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-11-25 17:16:19 +11:00
miz-take
fcd96fc8e0 Improve the error handling esp. after failed malloc's
Reviewed-by: Angus Salkeld <asalkeld@redhat.com>
2011-11-08 09:50:38 +11:00
Angus Salkeld
98493d9ae8 Change Lindent options to break the procedure type.
so change:
int foo(void)

to

int
foo(void)

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-06-22 14:19:14 +10:00
Angus Salkeld
77b6e15a85 Consistently prepend "qb-" to files in /dev/shm
Dietmar: can you confirm this works for you?

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-06-20 16:36:26 +10:00
Angus Salkeld
4a3536e72c Re-fix mmap() woes on sparc.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-06-07 19:53:26 +10:00
Angus Salkeld
34e9820230 Revert "Fix ringbuffer creation on sparc"
This reverts commit 683296f180.
2011-06-03 22:43:09 +10:00
Angus Salkeld
683296f180 Fix ringbuffer creation on sparc
On the first call to qb_rb_open() we try using a number of
page sizes. This because the system might have CONFIG_HUGETLB_PAGE_SIZE
defined in their kernel. So even though sysconf() returns 2K or 4K
some arch's mmap() require alignment on these boundaries.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-06-02 11:42:14 +10:00
Angus Salkeld
9666c392cb Fix some spelling.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-06-02 11:40:39 +10:00
Angus Salkeld
da150fcb22 IPC: misc cleanup & logging improvements
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-05-31 19:03:50 +10:00
Виноградов Василий
8880465924 RB: More consistent behavior when closing a ringbuffer
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-05-30 21:16:35 +10:00
Angus Salkeld
da5ea1345e Remove all the C++ comments
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-05-26 10:39:36 +10:00
Jim Meyering
d8a7fffd4d qb_rb_write_to_file clean-up
* lib/ringbuffer.c (qb_rb_write_to_file): Remove dead initialization
and redundant "result < 0" tests.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-05-24 09:45:17 +10:00