Commit Graph

84 Commits

Author SHA1 Message Date
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
Angus Salkeld
6acc19bdc3 COV 10: fix mem leaks in qb_rb_create_from_file()
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-05-20 21:31:29 +10:00
Angus Salkeld
8b5d664876 COV 9: fix mem leak in qb_rb_open error condition
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-05-20 21:31:29 +10:00
Angus Salkeld
943b1c646b fix the FIXME's Jim pointed out
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-05-18 11:11:14 +10:00
Jim Meyering
9c467cb150 add FIXME comments for other NULL-deref-upon-OOM problems
* lib/ipc_us.c (handle_new_connection):
* lib/loop_job.c (qb_loop_jobs_create):
* lib/loop_poll.c (qb_loop_poll_create):
* lib/loop_timerlist.c (qb_loop_timer_create):
* lib/ringbuffer.c (qb_rb_open):
* lib/ipcc.c (qb_ipcc_connect): Likewise.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-05-17 21:32:29 +10:00
Angus Salkeld
191b71a8b7 LOG: add a new "tags" field
this is a tags that is used by the caller to:
- define the message as an external message (needs free'ing)
- define a feature or susbsytem that can be printed in the log message.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-03-31 21:37:44 +11:00
Angus Salkeld
3452d162d2 LOG: add a qb_perror() function
- Add an internal version too
- Update the library code to use it.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-03-28 11:12:47 +11:00
Angus Salkeld
a215e856d8 LOG: fix splint warnings
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-03-27 21:01:11 +11:00