[PATCH 1/2] config: use newer AC_COMPILE_IFELSE()
by Angus Salkeld
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
configure.ac | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/configure.ac b/configure.ac
index b97ed8f..16f15a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,22 +153,21 @@ AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
[],
[#include <sys/un.h>])
-
AC_MSG_CHECKING(looking for union semun in sys/sem.h)
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-],[
-union semun arg;
-semctl(0, 0, 0, arg);
-], [have_union_semun="1" union_semun=yes ]
-msg=yes, [
-have_union_semun="0"
-msg=no ] )
-AC_MSG_RESULT([$msg])
-AM_CONDITIONAL(HAVE_SEMUN,
- [test "x$have_union_semun" = xyes])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[#include <sys/types.h>
+ #include <sys/ipc.h>
+ #include <sys/sem.h>]],
+[[union semun arg; semctl(0, 0, 0, arg);]])],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED([HAVE_SEMUN], 1, [Define to 1 if you have union semun.])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ]
+ )
+
# Checks for library functions.
AC_FUNC_CHOWN
--
1.7.10.2
11 years, 10 months
[PATCH] Check for union semun properly
by Angus Salkeld
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
configure.ac | 21 +++++++++++++++++----
lib/ringbuffer_int.h | 4 ++--
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5de6604..59f1b31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,6 +152,23 @@ AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
[],
[#include <sys/un.h>])
+
+AC_MSG_CHECKING(looking for union semun in sys/sem.h)
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+],[
+union semun arg;
+semctl(0, 0, 0, arg);
+], [have_union_semun="1" union_semun=yes ]
+msg=yes, [
+have_union_semun="0"
+msg=no ] )
+AC_MSG_RESULT([$msg])
+AM_CONDITIONAL(HAVE_SEMUN,
+ [test "x$have_union_semun" = xyes])
+
# Checks for library functions.
AC_FUNC_CHOWN
AC_FUNC_FORK
@@ -274,8 +291,6 @@ case "$host_os" in
[Compiling for FreeBSD >= 8 platform])
;;
*netbsd*)
- AC_DEFINE_UNQUOTED([_SEM_SEMUN_UNDEFINED], [1],
- [The semun structure is undefined])
;;
esac
AC_MSG_RESULT([BSD])
@@ -285,8 +300,6 @@ case "$host_os" in
[Compiling for Solaris platform])
AC_DEFINE_UNQUOTED([TS_CLASS], [1],
[Prevent being scheduled RR])
- AC_DEFINE_UNQUOTED([_SEM_SEMUN_UNDEFINED], [1],
- [The semun structure is undefined])
CP=rsync
AC_MSG_RESULT([Solaris])
;;
diff --git a/lib/ringbuffer_int.h b/lib/ringbuffer_int.h
index 762dc44..dfdee17 100644
--- a/lib/ringbuffer_int.h
+++ b/lib/ringbuffer_int.h
@@ -72,13 +72,13 @@ struct qb_ringbuffer_s {
void qb_rb_force_close(qb_ringbuffer_t * rb);
-#if defined(_SEM_SEMUN_UNDEFINED)
+#ifndef HAVE_SEMUN
union semun {
int32_t val;
struct semid_ds *buf;
unsigned short int *array;
struct seminfo *__buf;
};
-#endif /* _SEM_SEMUN_UNDEFINED */
+#endif /* HAVE_SEMUN */
#endif /* _RINGBUFFER_H_ */
--
1.7.10.2
11 years, 10 months
[PATCH] Blackbox: provide more space for log messages when reading from the blackbox.
by Angus Salkeld
This is to allow for the header (16bytes and variable length function).
so if someone has a function name > 400 chars it will break. I
recon that will do:)
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
lib/log_blackbox.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/log_blackbox.c b/lib/log_blackbox.c
index 7f15e56..16666ca 100644
--- a/lib/log_blackbox.c
+++ b/lib/log_blackbox.c
@@ -142,7 +142,8 @@ qb_log_blackbox_print_from_file(const char *bb_filename)
{
qb_ringbuffer_t *instance;
ssize_t bytes_read;
- char chunk[512];
+ int max_size = 2 * QB_LOG_MAX_LEN;
+ char *chunk;
int fd;
char time_buf[64];
@@ -156,6 +157,7 @@ qb_log_blackbox_print_from_file(const char *bb_filename)
if (instance == NULL) {
return;
}
+ chunk = malloc(max_size);
do {
char *ptr;
@@ -167,7 +169,7 @@ qb_log_blackbox_print_from_file(const char *bb_filename)
char message[QB_LOG_MAX_LEN];
uint32_t u32;
- bytes_read = qb_rb_chunk_read(instance, chunk, 512, 0);
+ bytes_read = qb_rb_chunk_read(instance, chunk, max_size, 0);
ptr = chunk;
if (bytes_read > 0) {
struct tm *tm;
@@ -207,4 +209,5 @@ qb_log_blackbox_print_from_file(const char *bb_filename)
}
} while (bytes_read > 0);
qb_rb_close(instance);
+ free(chunk);
}
--
1.7.10.2
11 years, 10 months
[PATCH] Add a tool to dump the blackbox.
by Angus Salkeld
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
Makefile.am | 2 +-
configure.ac | 1 +
docs/Makefile.am | 2 +-
docs/man8/qb-blackbox.8 | 59 +++++++++++++++++++++++++++++++++++++++++++++++
libqb.spec.in | 1 +
tools/.gitignore | 1 +
tools/Makefile.am | 28 ++++++++++++++++++++++
tools/qb_blackbox.c | 29 +++++++++++++++++++++++
8 files changed, 121 insertions(+), 2 deletions(-)
create mode 100644 docs/man8/qb-blackbox.8
create mode 100644 tools/.gitignore
create mode 100644 tools/Makefile.am
create mode 100644 tools/qb_blackbox.c
diff --git a/Makefile.am b/Makefile.am
index 099e1d0..74a464e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,7 +41,7 @@ ACLOCAL_AMFLAGS = -I m4
dist_doc_DATA = COPYING INSTALL README.markdown
-SUBDIRS = include lib docs tests examples
+SUBDIRS = include lib docs tools tests examples
doxygen:
$(MAKE) -C docs doxygen
diff --git a/configure.ac b/configure.ac
index ace78b4..5de6604 100644
--- a/configure.ac
+++ b/configure.ac
@@ -530,6 +530,7 @@ AC_CONFIG_FILES([Makefile
include/qb/Makefile
lib/Makefile
lib/libqb.pc
+ tools/Makefile
tests/Makefile
examples/Makefile
docs/Makefile
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 257ddd4..9e5439c 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -27,7 +27,7 @@ dependant_headers = $(wildcard $(inc_dir)/qb*.h)
dist_man_MANS = man3/qbipcc.h.3 man3/qbipcs.h.3 man3/qbatomic.h.3 \
man3/qbhdb.h.3 man3/qbipc_common.h.3 man3/qblist.h.3 \
man3/qbloop.h.3 man3/qbutil.h.3 man3/qbarray.h.3 \
- man3/qblog.h.3 man3/qbmap.h.3
+ man3/qblog.h.3 man3/qbmap.h.3 man8/qb-blackbox.8
$(dist_man_MANS): man.dox $(dependant_headers)
diff --git a/docs/man8/qb-blackbox.8 b/docs/man8/qb-blackbox.8
new file mode 100644
index 0000000..976848c
--- /dev/null
+++ b/docs/man8/qb-blackbox.8
@@ -0,0 +1,59 @@
+.\"/*
+.\" * Copyright (C) 2012 Red Hat, Inc.
+.\" *
+.\" * Author: Angus Salkeld <asalkeld(a)redhat.com>
+.\" *
+.\" * This file is part of libqb.
+.\" *
+.\" * libqb is free software: you can redistribute it and/or modify
+.\" * it under the terms of the GNU Lesser General Public License as published by
+.\" * the Free Software Foundation, either version 2.1 of the License, or
+.\" * (at your option) any later version.
+.\" *
+.\" * libqb is distributed in the hope that it will be useful,
+.\" * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" * GNU Lesser General Public License for more details.
+.\" *
+.\" * You should have received a copy of the GNU Lesser General Public License
+.\" * along with libqb. If not, see <http://www.gnu.org/licenses/>.
+.\" */
+.TH QB-BLACKBOX 8 2012-05-28
+.SH NAME
+qb-blackbox \- Display "flight data" from the "blackbox".
+.SH SYNOPSIS
+.B "qb-blackbox <blackbox files>..."
+.SH DESCRIPTION
+.B qb-blackbox
+Print out the logs (including debug logs) that were recorded using libqb's blackbox.
+.SH EXAMPLES
+.TP
+Get info to help developers diagnose a crash.
+.br
+$ qb-blackbox /var/lib/corosync/fdata
+.br
+Dumping the contents of /var/lib/corosync/fdata
+.br
+Mar 23 20:58:57 message_handler_orf_token():3677 install seq 0 aru 0 high seq received 0
+.br
+Mar 23 20:58:57 message_handler_orf_token():3696 retrans flag count 4 token aru 0 install seq 0 aru 0 0
+.br
+Mar 23 20:58:57 old_ring_state_reset():1487 Resetting old ring state
+.br
+Mar 23 20:58:57 deliver_messages_from_recovery_to_regular():1693 recovery to regular 1-0
+.br
+Mar 23 20:58:57 memb_state_operational_enter():1779 Delivering to app 1 to 0
+.br
+Mar 23 20:58:57 sync_abort():594 ENTERING sync_abort()
+.br
+Mar 23 20:58:57 sync_save_transitional():586 ENTERING sync_save_transitional()
+.br
+Mar 23 20:58:57 member_object_joined():301 Member joined: r(0) ip(192.168.122.1)
+.br
+Mar 23 20:58:57 sync_abort():594 ENTERING sync_abort()
+.br
+.SH SEE ALSO
+.BR qblog.h (3),
+.SH AUTHOR
+Angus Salkeld
+.PP
diff --git a/libqb.spec.in b/libqb.spec.in
index f734656..afba44e 100644
--- a/libqb.spec.in
+++ b/libqb.spec.in
@@ -46,6 +46,7 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc COPYING
+%{_sbindir}/qb-blackbox
%{_libdir}/libqb.so.*
%package devel
diff --git a/tools/.gitignore b/tools/.gitignore
new file mode 100644
index 0000000..0a87671
--- /dev/null
+++ b/tools/.gitignore
@@ -0,0 +1 @@
+qb-blackbox
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644
index 0000000..7125831
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,28 @@
+# Copyright (c) 2011 Red Hat, Inc.
+#
+# Authors: Angus Salkeld <asalkeld(a)redhat.com>
+#
+# This file is part of libqb.
+#
+# libqb is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# libqb is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with libqb. If not, see <http://www.gnu.org/licenses/>.
+#
+MAINTAINERCLEANFILES = Makefiles.in
+EXTRA_DIST =
+CLEANFILES =
+
+sbin_PROGRAMS = qb-blackbox
+
+qb_blackbox_SOURCES = qb_blackbox.c $(top_builddir)/include/qb/qblog.h
+qb_blackbox_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
+qb_blackbox_LDADD = $(LIB_RT) $(top_builddir)/lib/libqb.la
diff --git a/tools/qb_blackbox.c b/tools/qb_blackbox.c
new file mode 100644
index 0000000..0b3f310
--- /dev/null
+++ b/tools/qb_blackbox.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 Andrew Beekhof <andrew(a)beekhof.net>
+ *
+ * libqb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * libqb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libqb. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <qb/qblog.h>
+
+int
+main(int argc, char **argv)
+{
+ int lpc = 0;
+ for(lpc = 1; lpc < argc && argv[lpc] != NULL; lpc++) {
+ printf("Dumping the contents of %s\n", argv[lpc]);
+ qb_log_blackbox_print_from_file(argv[lpc]);
+ }
+ return 0;
+}
--
1.7.10.2
11 years, 11 months