Commit Graph

102 Commits

Author SHA1 Message Date
Russell Bryant
a53e402912 logsys.c: Use snprintf() instead of sprintf().
Change a couple of string functions to use the the output length
limiting counterpart.

Signed-off-by: Russell Bryant <russell@russellbryant.net>
2011-05-08 02:42:47 -05:00
Angus Salkeld
0ad2494ae7 Fix some "set but not used" warnings [-Wunused-but-set-variable]
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-03-16 07:13:42 +11:00
Russell Bryant
a609f79f1f Ensure that strings are null terminated after strncpy().
From the strcpy(3) man page, the following warning is given:
  The strncpy() function is similar, except that at most n bytes of src
  are  copied.  Warning: If there is no null byte among the first n bytes
  of src, the string placed in dest will not be null-terminated.

The current corosync code base does not take this warning into account
when using strncpy, potentially resulting in non-null terminated strings.

Signed-off-by: Russell Bryant <russell@russellbryant.net>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-03-07 08:30:03 -06:00
Jan Friesse
c5e8237325 logsys: Properly lock flt data before dump
Data needs to be locked, otherwise resulting fdata file may be
incorrect.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-02-22 10:11:11 +01:00
Jan Friesse
88515e3d20 logsys: Don't leak fd on successful fdata dump
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-02-22 10:09:10 +01:00
Steven Dake
7b832592b0 Fix problem where flight data leaks files in /dev/shm when corosync is
restarted continuously via init scripts.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2964 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-06-28 22:15:48 +00:00
Steven Dake
402c553dd2 Update logsys to use proper ring buffer on file backed map
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2922 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-06-09 20:14:50 +00:00
Steven Dake
b8af7c3764 sem_wait can be interrupted by signal. Handle interruption properly.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2920 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-06-03 22:05:17 +00:00
Steven Dake
c3a6b98bdc The static function 'decode_mode()' is used by the static function
'dump_subsys_config()' which is is turn used by the static function
'dump_full_config()' which is never used.

Are these functions used by someone using some magic? I did not find
any reference and even the flag LOGSYS_DEBUG, which prevents them from
compiling, does not exist at some other point.

If these functions are really not used, please remove them (because at
least one of them has a buffer overflow). Patch against 1.2.3
is attached.

If there is a need for these functions, I'll send a patch to fix
the 'decode_mode()' function.

Kind regards

Andreas Florath

Signed-off-by: Andreas Florath <gnu4u at flonatel dot org>



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2915 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-05-28 20:39:58 +00:00
Steven Dake
4561c6dcf6 Fix problem where memcpy operation occurs incorrectly to copy schedule
parameter data resulting in priority inversion deadlocks on single cpu systems.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2906 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-05-26 17:47:39 +00:00
Angus Salkeld
4ff33854ad add __attribute__((noreturn)) to functions that always exit.
we had some __attribute__((__noreturn__))
and some    __attribute__((noreturn))

I made them all: __attribute__((noreturn))



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2853 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-05-19 04:34:53 +00:00
Angus Salkeld
ad71b66c7b cov (many): make sure all _set() functions return a signed int
in the body it can return -1, and callers check for -1.
but the return type is unsigned int?



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2849 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-05-18 00:46:08 +00:00
Steven Dake
d4f92c864a Fix problem where logsys messages are not flushed at exit before worker thread
is created.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2846 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-05-18 00:13:54 +00:00
Steven Dake
5e8f1a730f logsys rework to deal with memory corruption around debug:on configurations.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2816 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-05-13 04:36:42 +00:00
Jan Friesse
12c5f31a89 Handle some valgrind errors
- Memset for res_setup variable in coroipcs:req_setup_send
- Two memset in logsys for buffers
- Problem in corosync_totem_stats_updater where avg_token_holdtime has
size of avg_backlog_calc
- corosync_totem_stats_init where avg_backlog_calc is 32 bits (not 64)
- objdb problem if new_valie_len != object->value_len. In such case
newly allocated memory is not initialized and in some situations,
value_len is not updated.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2787 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-04-23 08:03:05 +00:00
Steven Dake
2cc62fdd34 Fix lockup that occurs rarely with pthread_join() is called in atexit()
handler.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2719 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-03-22 22:07:01 +00:00
Angus Salkeld
20f3331d0e convert strerror() into strerror_r()
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2665 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-02-25 19:28:36 +00:00
Jan Friesse
c6242c9a52 Remove potentially thread unsafe call of strftime
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2571 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-12-07 17:14:44 +00:00
Angus Salkeld
34ddb1cb14 COVERITY 12: prevent overrun of logsys output buffers.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2547 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-11-22 23:19:41 +00:00
Steven Dake
60d50de816 Remove warning in logsys compile related to const correctness.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2463 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-09-20 06:56:02 +00:00
Angus Salkeld
f3b92eb6b3 Only insert the filename into the log, not the path.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2408 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-09-09 00:25:36 +00:00
Angus Salkeld
e1ceabc6ef Remove a double unlock in logsys.
In logsys there are a number of XYZ_unlocked() functions that are called
like this:

       pthread_mutex_lock (&logsys_config_mutex);

       XYZ_unlocked();

       pthread_mutex_unlock (&logsys_config_mutex);

The XYZ_unlocked() functions should not do any (un)locking.
But _logsys_config_subsys_get_unlocked() unlocks if it finds the subsys.
This means that there is 1 lock and 2 unlocks.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2404 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-09-07 08:33:23 +00:00
Fabio M. Di Nitto
6115c85328 logsys: fix segfault in logsys_thread_priority_set
logsys_thread_priority_set expects that wthread is already running
but doesn't perform any check if it is.

if logsys_thread_priority_set is invoked before forking the thread,
a segfault is guaranteed.

this changes to logsys_thread_priority_set ensure that a request
for a new scheduler priority is queued if the wthread is not
created yet and the new scheduler parameters are applied as early
as possible after the thread is created.

At the same time:

- add a few comments on clean up that needs to be done
- remove a redundant check for policy != SCHED_OTHER as that's
  corosync need specific. logsys should simply accept the request
  and apply it.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2382 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-08-10 05:32:58 +00:00
Steven Dake
0cf6c6c7db Add tests for posix scheduling apis to configure.ac and use them to determine
if we should set scheduling priorities or not.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2277 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-21 16:33:25 +00:00
Fabio M. Di Nitto
951a416532 flight recorder: enable temporary 0 buffer size protection
The flight recoder doesn't handle a 0 byte allocation properly
and it would fail miserably by allocating a single PAGE_SIZE
to handle the logging. That means an enormous performance hit
because of the constant wrapping around the buffer.

If any requested buffer is < 64000 bytes, then force to at least
64000.

In future we will be able to handle small buffers properly, but
for now enable a simple workaround to protect us and the user.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2256 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-18 18:14:00 +00:00
Fabio M. Di Nitto
9a94d633cf flight recorder: switch from int to bytes for requested allocation
The flight recoder buffer size as specified in LOGSYS_DECLARE_SYSTEM
or _logsys_rec_init was expressed in number of ints. A developer asking
to allocate 512K would get a 2M allocation on a machine with sizeof(int) = 4.

This is confusing and the patch addresses it:

- rename rec_size to fltsize for external API (no type change),
  because rec_size is used many times internally for other reasons
  and it can be confusing.

- rename size to fltsize in _logsys_rec_init.

- document what we allocate and why.

- swap comments around to match the code.

- introduce a simple macro to perform rounding (stolen from linux-2.6.git).

- start shaping fdata header to better handle dynamic values:
  * write the flt_data_size as first unsigned int the header.
  * change corosync-fplay to read the value and alloc the right amount
    of memory instead of hardcoding it again.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2255 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-18 17:40:41 +00:00
Fabio M. Di Nitto
ad4a6c63ea flight recorder: don't hardcode max arguments everywhere
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2251 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-18 05:33:48 +00:00
Fabio M. Di Nitto
6d5ce092a1 logsys: port to new packed rec_ident version
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2250 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-18 05:32:56 +00:00
Fabio M. Di Nitto
5597a2381f logsys: merge tags into rec_ident
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2246 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-18 05:15:10 +00:00
Steven Dake
65b0fff497 Port of logsys to Solaris.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2209 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-07 00:42:40 +00:00
Jan Friesse
caceb59f1e Remove duplicity in logsys code
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2185 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-05-18 09:42:57 +00:00
Fabio M. Di Nitto
8c7a454e2e Fix output to syslog
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2184 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-05-13 09:25:08 +00:00
Fabio M. Di Nitto
75c9085204 Fix logsys TAG handling
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2180 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-05-13 03:59:47 +00:00
Jim Meyering
fd20c4e799 logsys.c: avoid possibility of buffer overrun
* exec/logsys.c (strcpy_cutoff): Add buf_len parameter, and never
write more than this number of bytes into "dest".
Change type of "cutoff" parameter from int to size_t.
Sentinel value changes from -1 to 0.
(log_printf_to_logs): Adapt to those changes.
Reverse condition of test so the much-shorter block is the "if-block".
Factor out a common subexpression for readability.
Exit the loop if output_buffer_idx ever reaches sizeof(output_buffer).

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2178 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-05-12 08:35:17 +00:00
Jim Meyering
d04702854b logsys.c: avoid redundant strlen in else-block
* exec/logsys.c (strcpy_cutoff): Also, with a field width (aka cutoff),
and a shorter-than-field-width string, don't write the same memory
twice: once with strncpy using NUL bytes, then again with spaces
via the memset.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2177 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-05-12 08:35:09 +00:00
Jim Meyering
fbbc934196 logsys.c: factor out some duplication
* exec/logsys.c (log_printf_to_logs): Factor out repeated calls to
strcpy_cutoff.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2176 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-05-12 08:35:01 +00:00
Fabio M. Di Nitto
6a9ebd8297 Add debugging code to logsys.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2175 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-05-12 05:36:09 +00:00
Fabio M. Di Nitto
4572f1124a Fix logging date format and add missing daemon name
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2173 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-05-11 08:17:53 +00:00
Fabio M. Di Nitto
490c262b3e Fix debug: on option for logging purposes
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2160 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-27 11:37:59 +00:00
Fabio M. Di Nitto
21902efa1b add max limit error checks in logsys
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2159 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-27 11:36:53 +00:00
Jim Meyering
0b264ba292 logsys.c: avoid an unnecessary strlen call
* exec/logsys.c (strcpy_cutoff): Use strlen, then memcpy,
not strcpy, then strlen.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2143 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-24 09:55:21 +00:00
Steven Dake
2505b53703 Add logsys yield counter for the logsys thread.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2139 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-23 19:21:35 +00:00
Steven Dake
ed7d054e55 Remove priority inversion in logsys.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2130 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-23 15:24:29 +00:00
Jim Meyering
85d1e26bb1 logsys.c: indent consistently
* exec/logsys.c (_logsys_log_printf): Indent with TABs to be
consistent with copied-from function, _logsys_log_vprintf.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2128 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-23 14:15:53 +00:00
Jan Friesse
0dc4aed441 Make ipc_log_printf function working by adding _logsys_log_vprintf, which
is mostly same as _logsys_log_printf but takes va_list as argument.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2127 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-23 12:29:26 +00:00
Fabio M. Di Nitto
230b85044f Kill all asserts from logsys and handle proper error return
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2121 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-22 09:14:23 +00:00
Jim Meyering
904a10ed38 remove all trailing blanks
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2117 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-22 08:03:55 +00:00
Fabio M. Di Nitto
c6a31d6145 Add logsys_flush logsys API call to signal the logging thread
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2103 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-21 04:38:49 +00:00
Fabio M. Di Nitto
1ecaa01b80 Fix output filtering when debug is enabled
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2101 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-21 04:02:19 +00:00
Fabio M. Di Nitto
0f942b2ed9 Improve logsys error handling in logsys_format_set
and logsys_config_file_set_unlocked.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2096 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-20 10:43:37 +00:00