Commit Graph

82 Commits

Author SHA1 Message Date
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
Fabio M. Di Nitto
9b2dd8a43e readd early log level check for performance reasons.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2093 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-20 07:08:42 +00:00
Fabio M. Di Nitto
c3c75acfd2 Add logsys v3
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2091 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-20 04:28:33 +00:00
Jim Meyering
a549daedca logsys.h (logsys_format_set): Change return type, adjust param type.
* include/corosync/engine/logsys.h:
* exec/logsys.c (logsys_format_set): Return -1 upon strdup failure.
Change type of param to "const char *".
* exec/logsys.c (logsys_init): Adjust use.
* exec/mainconfig.c (corosync_main_config_read_logging): Adjust uses.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2009 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-07 13:01:55 +00:00
Fabio M. Di Nitto
243abac616 Drop unrequired struct
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1992 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-03 05:46:01 +00:00
Steven Dake
870046d065 Patch to use snprintf where appropriate to avoid buffer overrun.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1990 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-02 18:49:24 +00:00
Fabio M. Di Nitto
2a5bd53771 Fix internal API usage and add support for file_name
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1976 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-01 09:01:52 +00:00
Fabio M. Di Nitto
e770695cd0 Fix build warning
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1975 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-01 05:48:03 +00:00
Jim Meyering
588dd0b16d logsys.c: avoid 1 warning
* exec/logsys.c (logsys_conf): Add const.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1968 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:17:42 +00:00
Jim Meyering
7b73cfe841 logsys.c: avoid 1 warning
* exec/logsys.c (logsys_worker_thread): Mark function as "noreturn".

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1966 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:17:27 +00:00
Jim Meyering
1280f900cb logsys.c: fix two more warnings
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1945 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:14:08 +00:00
Jim Meyering
cc6eed7042 in progress: avoid warnings
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1943 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:13:47 +00:00
Jim Meyering
e487affc01 logsys_config_facility_set: make "name" parameter const
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1919 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:09:56 +00:00
Jim Meyering
217c5bed8d logsys: detect write failure and avoid a file descriptor leak
* exec/logsys.c (logsys_log_rec_store): Close output file descriptor
and detect any failure.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1915 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 14:33:49 +00:00
Steven Dake
1b1c0b657a Appears to fix compile errors on macosx.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1909 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-24 16:03:46 +00:00
Fabio M. Di Nitto
031c02f589 - Every .c file should include "config.h" to get the right defines...
- services/Makefile.am: add include search paths for config.h

- include/corosync/cs_config.h.in exports LCRSODIR and SOCKETDIR

- tools/Makefile.am: drop -D defines for dirs that are now in
cs_config.h or config.h

- configure.ac: sanitize prefix and exec_prefix paths. Export DIRS in
*config.h

- lib/Makefile.am: : drop -D defines for dirs that are now in
cs_config.h or config.h. Add rule to build lcr_ifact.o or building from
lib/ fails miserably



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1877 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-19 12:58:53 +00:00
Steven Dake
64aab2e950 Remove const warnings relating to logsys global definitions.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1806 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-10 09:48:34 +00:00
Steven Dake
b113dd2e19 Remove logsys warnings.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1805 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-10 09:40:54 +00:00
Fabio M. Di Nitto
8c4bcde5c2 Add logsys_format_get to logsys API.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1797 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-10 08:03:50 +00:00
Fabio M. Di Nitto
f7c4cea567 logsys_format_set should use its own internal copy of format_buffer
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1796 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-10 07:11:17 +00:00
Fabio M. Di Nitto
f83aa4f876 Allow logsys_format_set to reset to default.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1792 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-06 07:09:24 +00:00