Commit Graph

119 Commits

Author SHA1 Message Date
Angus Salkeld
41b4416bd4 Remove unused function logsys_priority_name_get()
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2012-03-09 21:54:51 +11:00
Angus Salkeld
f628ccba8b Add pid, hostname and process name to the logfile
Note this is only for file targets not stderr or syslog.

https://bugzilla.redhat.com/show_bug.cgi?id=789925

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2012-03-09 21:54:51 +11:00
Steven Dake
2ad0cdc832 Update copyright header dates in exec directory
Signed-off-by: Steven Dake <sdake@redhat.com>
Reviewed-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-13 17:05:04 -07:00
Angus Salkeld
8992acb815 LOG: add libqb as a "subsys"
So we can see libqb internal logs

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-02-07 10:53:56 +11:00
Jan Friesse
33e5ce8d56 Show correct error when open of logfile failed
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-02-02 09:30:49 +01:00
Angus Salkeld
3698b78de9 LOG: make sure that debug works to syslog
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-01-25 11:33:09 +11:00
Steven Dake
8ad583a54c Move logsys.c into corosync binary instead of a shared object
Our preferred shared logging system is exported via the libqb library.  As
a result, the corosync project no longer needs to export logsys.so and the
code can be directly included in the binary.  The header file can also be
removed.

Signed-off-by: Steven Dake <sdake@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-01-06 18:19:59 -07:00
Angus Salkeld
c317ee433f LOG: Fix a crash in the shutdown.
Reviewed-by: Steven Dake <sdake@redhat.com>
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-12-13 15:00:42 +11:00
Angus Salkeld
0fc51c40fd LOG: cleanup logging resources at exit
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-11-11 09:05:08 +11:00
Angus Salkeld
2cf37d4063 Set the size of the blackbox to the size on flatiron
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-10-22 17:42:53 +11:00
Angus Salkeld
78a5260c06 LOG: use libqb facility conversion functions
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-10-21 19:34:43 +11:00
Angus Salkeld
0e58141a2f LOG: get logging to file working correctly
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-10-21 19:34:43 +11:00
Angus Salkeld
26a6e26f57 LOG: Fix debugging
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-10-21 19:34:43 +11:00
Angus Salkeld
37e17e7a94 libqb: logging & trace
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-08-09 10:37:16 +10:00
Jan Friesse
8c717c22b2 Remove spinlocks
Spinlocks are now removed, because even spinlock can improve
speed is some special cases, in most cases it makes corosync CPU usage
much more intensive and less responsive then if only mutexes are used.

What we were doing is:
pthread_mutex_lock
pthread_spin_lock
pthread_spin_unlock
pthread_mutex_unlock

what is not safe.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-06-29 12:01:54 +02:00
Jerome Flesch
00434a4f10 Fix usage of strerror_r()/perror()
Signed-off-by: Jerome Flesch <jerome.flesch@netasq.com>
Reviewed-by: Angus Salkeld <asalkeld@redhat.com>
2011-06-28 09:56:58 +02:00
Jan Friesse
d76bb76d1f logsys: _logsys_wthread_create never returns != 0
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-06-03 10:59:17 +02:00
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