Commit 29a51840 authored by Michael Jeanson's avatar Michael Jeanson

New upstream version 2.10.2

parent cd47debc
2018-08-20 (World Mosquito Day) lttng-ust 2.10.2
* Fix: add liblttng-ust dependency to liblttng-ust-fd
* Fix: use LIBDL/LIBC_DL to select either libdl or libc
* Fix: AM_CONDITIONAL should be outside AS_IF block
* Fix: build jni libs with openjdk >= 10
* Fix: ustfork: save and restore errno in syscall wrappers
* Fix: cache the result of getpid() internally
* Fix: reset cached vpid context on fork
* Fix: string comparison on incorrect length in context provider
* Fix: remove for() loop initial declarations
* Use ust_lock during sock_info operations for atomicity against fork
* Force tracked fd to be bigger than STDERR_FILENO
2017-11-30 (National Mason Jar Day) lttng-ust 2.10.1
* Fix: specify SONAME in python-lttngust LoadLibrary
* Fix: ensure fd tracker is initialized when called from constructors
......
......@@ -110,11 +110,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
......
......@@ -1434,10 +1434,10 @@ m4_include([m4/ax_prog_javac_works.m4])
m4_include([m4/ax_prog_javah.m4])
m4_include([m4/ax_sys_weak_alias.m4])
m4_include([m4/ax_try_compile_java.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
m4_include([m4/ltsugar.m4])
m4_include([m4/ltversion.m4])
m4_include([m4/lt~obsolete.m4])
m4_include([m4/pprint.m4])
m4_include([m4/rw_prog_cxx_works.m4])
m4_include([config/libtool.m4])
m4_include([config/ltoptions.m4])
m4_include([config/ltsugar.m4])
m4_include([config/ltversion.m4])
m4_include([config/lt~obsolete.m4])
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for lttng-ust 2.10.1.
# Generated by GNU Autoconf 2.69 for lttng-ust 2.10.2.
#
# Report bugs to <mathieu dot desnoyers at efficios dot com>.
#
......@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='lttng-ust'
PACKAGE_TARNAME='lttng-ust'
PACKAGE_VERSION='2.10.1'
PACKAGE_STRING='lttng-ust 2.10.1'
PACKAGE_VERSION='2.10.2'
PACKAGE_STRING='lttng-ust 2.10.2'
PACKAGE_BUGREPORT='mathieu dot desnoyers at efficios dot com'
PACKAGE_URL='https://lttng.org'
......@@ -662,6 +662,8 @@ PYTHON_VERSION
PYTHON
BUILD_PYTHON_AGENT_FALSE
BUILD_PYTHON_AGENT_TRUE
HAVE_JAVAH_FALSE
HAVE_JAVAH_TRUE
JAVAH
_ACJNI_JAVAC
JAR
......@@ -1421,7 +1423,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures lttng-ust 2.10.1 to adapt to many kinds of systems.
\`configure' configures lttng-ust 2.10.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1493,7 +1495,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of lttng-ust 2.10.1:";;
short | recursive ) echo "Configuration of lttng-ust 2.10.2:";;
esac
cat <<\_ACEOF
......@@ -1651,7 +1653,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
lttng-ust configure 2.10.1
lttng-ust configure 2.10.2
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2371,7 +2373,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by lttng-ust $as_me 2.10.1, which was
It was created by lttng-ust $as_me 2.10.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -2727,7 +2729,7 @@ MAJOR_VERSION=2
MINOR_VERSION=10
PATCHLEVEL_VERSION=1
PATCHLEVEL_VERSION=2
# Following the numbering scheme proposed by libtool for the library version
......@@ -3375,7 +3377,7 @@ fi
# Define the identity of the package.
PACKAGE='lttng-ust'
VERSION='2.10.1'
VERSION='2.10.2'
cat >>confdefs.h <<_ACEOF
......@@ -20326,7 +20328,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 20329 "configure" */
/* #line 20331 "configure" */
public class Test {
}
EOF
......@@ -20501,7 +20503,7 @@ EOF
if $UUDECODE Test.uue; then
ac_cv_prog_uudecode_base64=yes
else
echo "configure: 20504: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: 20506: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: failed file was:" >&5
cat Test.uue >&5
ac_cv_prog_uudecode_base64=no
......@@ -20618,7 +20620,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 20621 "configure" */
/* #line 20623 "configure" */
public class Test {
}
EOF
......@@ -20653,7 +20655,7 @@ JAVA_TEST=Test.java
CLASS_TEST=Test.class
TEST=Test
cat << \EOF > $JAVA_TEST
/* [#]line 20656 "configure" */
/* [#]line 20658 "configure" */
public class Test {
public static void main (String args[]) {
System.exit (0);
......@@ -21070,6 +21072,15 @@ fi
fi
if test "x$JAVAH" != "x"; then
HAVE_JAVAH_TRUE=
HAVE_JAVAH_FALSE='#'
else
HAVE_JAVAH_TRUE='#'
HAVE_JAVAH_FALSE=
fi
if test "x$java_agent_log4j" = "xyes"; then :
......@@ -21111,7 +21122,7 @@ EOF
if $UUDECODE Test.uue; then
:
else
echo "configure: 21114: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: 21125: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: failed file was:" >&5
cat Test.uue >&5
ac_cv_prog_uudecode_base64=no
......@@ -21131,7 +21142,7 @@ EOF
else
cat << \EOF > Test.java
/* #line 21134 "configure" */
/* #line 21145 "configure" */
import org.apache.log4j.Logger;
public class Test {
......@@ -21945,6 +21956,10 @@ if test -z "${BUILD_JAVA_AGENT_WITH_LOG4J_TRUE}" && test -z "${BUILD_JAVA_AGENT_
as_fn_error $? "conditional \"BUILD_JAVA_AGENT_WITH_LOG4J\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_JAVAH_TRUE}" && test -z "${HAVE_JAVAH_FALSE}"; then
as_fn_error $? "conditional \"HAVE_JAVAH\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${BUILD_PYTHON_AGENT_TRUE}" && test -z "${BUILD_PYTHON_AGENT_FALSE}"; then
as_fn_error $? "conditional \"BUILD_PYTHON_AGENT\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
......@@ -22362,7 +22377,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by lttng-ust $as_me 2.10.1, which was
This file was extended by lttng-ust $as_me 2.10.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -22433,7 +22448,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
lttng-ust config.status 2.10.1
lttng-ust config.status 2.10.2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
dnl Version infos
m4_define([V_MAJOR], [2])
m4_define([V_MINOR], [10])
m4_define([V_PATCH], [1])
m4_define([V_PATCH], [2])
dnl m4_define([V_EXTRA], [])
m4_define([V_NAME], [[KeKriek]])
m4_define([V_DESC], [[From Brasserie Dunham, a sour mashed golden wheat ale fermented with local sour cherries from Tougas orchards. Fresh sweet cherry notes with some tartness, lively carbonation with a dry finish.]])
......@@ -345,6 +345,8 @@ AS_IF([test "x$jni_interface" = "xyes" || test "x$java_agent_jul" = "xyes" || te
CPPFLAGS="$saved_CPPFLAGS"
])
AM_CONDITIONAL([HAVE_JAVAH], [test "x$JAVAH" != "x"])
AS_IF([test "x$java_agent_log4j" = "xyes"], [
AX_CHECK_CLASSPATH
AX_CHECK_CLASS([org.apache.log4j.Logger])
......
......@@ -104,11 +104,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(dist_doc_DATA) \
......
......@@ -105,11 +105,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(dist_doc_examples_DATA) \
......
......@@ -114,11 +114,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
......
......@@ -2,12 +2,12 @@
.\" Title: lttng-gen-tp
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 11/30/2017
.\" Date: 08/20/2018
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.1
.\" Source: LTTng 2.10.2
.\" Language: English
.\"
.TH "LTTNG\-GEN\-TP" "1" "11/30/2017" "LTTng 2\&.10\&.1" "LTTng Manual"
.TH "LTTNG\-GEN\-TP" "1" "08/20/2018" "LTTng 2\&.10\&.2" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: lttng-ust-dl
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 11/30/2017
.\" Date: 08/20/2018
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.1
.\" Source: LTTng 2.10.2
.\" Language: English
.\"
.TH "LTTNG\-UST\-DL" "3" "11/30/2017" "LTTng 2\&.10\&.1" "LTTng Manual"
.TH "LTTNG\-UST\-DL" "3" "08/20/2018" "LTTng 2\&.10\&.2" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: lttng-ust-dl
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 11/30/2017
.\" Date: 08/20/2018
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.1
.\" Source: LTTng 2.10.2
.\" Language: English
.\"
.TH "LTTNG\-UST\-DL" "3" "11/30/2017" "LTTng 2\&.10\&.1" "LTTng Manual"
.TH "LTTNG\-UST\-DL" "3" "08/20/2018" "LTTng 2\&.10\&.2" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: lttng-ust
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 11/30/2017
.\" Date: 08/20/2018
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.1
.\" Source: LTTng 2.10.2
.\" Language: English
.\"
.TH "LTTNG\-UST" "3" "11/30/2017" "LTTng 2\&.10\&.1" "LTTng Manual"
.TH "LTTNG\-UST" "3" "08/20/2018" "LTTng 2\&.10\&.2" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: tracef
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 11/30/2017
.\" Date: 08/20/2018
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.1
.\" Source: LTTng 2.10.2
.\" Language: English
.\"
.TH "TRACEF" "3" "11/30/2017" "LTTng 2\&.10\&.1" "LTTng Manual"
.TH "TRACEF" "3" "08/20/2018" "LTTng 2\&.10\&.2" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: tracelog
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 11/30/2017
.\" Date: 08/20/2018
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.1
.\" Source: LTTng 2.10.2
.\" Language: English
.\"
.TH "TRACELOG" "3" "11/30/2017" "LTTng 2\&.10\&.1" "LTTng Manual"
.TH "TRACELOG" "3" "08/20/2018" "LTTng 2\&.10\&.2" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -104,11 +104,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(nobase_include_HEADERS) \
......
......@@ -27,7 +27,7 @@
#include <stdio.h>
void lttng_ust_init_fd_tracker(void);
void lttng_ust_add_fd_to_tracker(int fd);
int lttng_ust_add_fd_to_tracker(int fd);
void lttng_ust_delete_fd_from_tracker(int fd);
void lttng_ust_lock_fd_tracker(void);
void lttng_ust_unlock_fd_tracker(void);
......
......@@ -104,11 +104,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
......
......@@ -598,7 +598,7 @@ ssize_t ustcomm_recv_channel_from_sessiond(int sock,
{
void *chan_data;
ssize_t len, nr_fd;
int wakeup_fd;
int wakeup_fd, ret;
if (var_len > LTTNG_UST_CHANNEL_DATA_MAX_LEN) {
len = -EINVAL;
......@@ -627,9 +627,21 @@ ssize_t ustcomm_recv_channel_from_sessiond(int sock,
goto error_recv;
}
}
*_wakeup_fd = wakeup_fd;
lttng_ust_add_fd_to_tracker(wakeup_fd);
ret = lttng_ust_add_fd_to_tracker(wakeup_fd);
if (ret < 0) {
lttng_ust_unlock_fd_tracker();
ret = close(wakeup_fd);
if (ret) {
PERROR("close on wakeup_fd");
}
len = -EIO;
goto error_recv;
}
*_wakeup_fd = ret;
lttng_ust_unlock_fd_tracker();
*_chan_data = chan_data;
return len;
......@@ -661,10 +673,35 @@ int ustcomm_recv_stream_from_sessiond(int sock,
goto error;
}
}
*shm_fd = fds[0];
*wakeup_fd = fds[1];
lttng_ust_add_fd_to_tracker(fds[0]);
lttng_ust_add_fd_to_tracker(fds[1]);
ret = lttng_ust_add_fd_to_tracker(fds[0]);
if (ret < 0) {
lttng_ust_unlock_fd_tracker();
ret = close(fds[0]);
if (ret) {
PERROR("close on received shm_fd");
}
ret = -EIO;
goto error;
}
*shm_fd = ret;
ret = lttng_ust_add_fd_to_tracker(fds[1]);
if (ret < 0) {
lttng_ust_unlock_fd_tracker();
ret = close(*shm_fd);
if (ret) {
PERROR("close on shm_fd");
}
*shm_fd = -1;
ret = close(fds[1]);
if (ret) {
PERROR("close on received wakeup_fd");
}
ret = -EIO;
goto error;
}
*wakeup_fd = ret;
lttng_ust_unlock_fd_tracker();
return 0;
......
......@@ -47,6 +47,7 @@
#define IS_FD_VALID(fd) ((fd) >= 0 && (fd) < lttng_ust_max_fd)
#define GET_FD_SET_FOR_FD(fd, fd_sets) (&((fd_sets)[(fd) / FD_SETSIZE]))
#define CALC_INDEX_TO_SET(fd) ((fd) % FD_SETSIZE)
#define IS_FD_STD(fd) (IS_FD_VALID(fd) && (fd) <= STDERR_FILENO)
/* Check fd validity before calling these. */
#define ADD_FD_TO_SET(fd, fd_sets) \
......@@ -143,25 +144,112 @@ void lttng_ust_unlock_fd_tracker(void)
URCU_TLS(thread_fd_tracking) = 0;
}
static int dup_std_fd(int fd)
{
int ret, i;
int fd_to_close[STDERR_FILENO + 1];
int fd_to_close_count = 0;
int dup_cmd = F_DUPFD; /* Default command */
int fd_valid = -1;
if (!(IS_FD_STD(fd))) {
/* Should not be here */
ret = -1;
goto error;
}
/* Check for FD_CLOEXEC flag */
ret = fcntl(fd, F_GETFD);
if (ret < 0) {
PERROR("fcntl on f_getfd");
ret = -1;
goto error;
}
if (ret & FD_CLOEXEC) {
dup_cmd = F_DUPFD_CLOEXEC;
}
/* Perform dup */
for (i = 0; i < STDERR_FILENO + 1; i++) {
ret = fcntl(fd, dup_cmd, 0);
if (ret < 0) {
PERROR("fcntl dup fd");
goto error;
}
if (!(IS_FD_STD(ret))) {
/* fd is outside of STD range, use it. */
fd_valid = ret;
/* Close fd received as argument. */
fd_to_close[i] = fd;
fd_to_close_count++;
break;
}
fd_to_close[i] = ret;
fd_to_close_count++;
}
/* Close intermediary fds */
for (i = 0; i < fd_to_close_count; i++) {
ret = close(fd_to_close[i]);
if (ret) {
PERROR("close on temporary fd: %d.", fd_to_close[i]);
/*
* Not using an abort here would yield a complicated
* error handling for the caller. If a failure occurs
* here, the system is already in a bad state.
*/
abort();
}
}
ret = fd_valid;
error:
return ret;
}
/*
* Needs to be called with ust_safe_guard_fd_mutex held when opening the fd.
* Has strict checking of fd validity.
*
* If fd <= 2, dup the fd until fd > 2. This enables us to bypass
* problems that can be encountered if UST uses stdin, stdout, stderr
* fds for internal use (daemon etc.). This can happen if the
* application closes either of those file descriptors. Intermediary fds
* are closed as needed.
*
* Return -1 on error.
*
*/
void lttng_ust_add_fd_to_tracker(int fd)
int lttng_ust_add_fd_to_tracker(int fd)
{
int ret;
/*
* Ensure the tracker is initialized when called from
* constructors.
*/
lttng_ust_init_fd_tracker();
assert(URCU_TLS(thread_fd_tracking));
if (IS_FD_STD(fd)) {
ret = dup_std_fd(fd);
if (ret < 0) {
goto error;
}
fd = ret;
}
/* Trying to add an fd which we can not accommodate. */
assert(IS_FD_VALID(fd));
/* Setting an fd thats already set. */
assert(!IS_FD_SET(fd, lttng_fd_set));
ADD_FD_TO_SET(fd, lttng_fd_set);
return fd;
error:
return ret;
}
/*
......
......@@ -104,11 +104,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
......
......@@ -109,11 +109,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
......
......@@ -106,11 +106,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
......
......@@ -5,6 +5,7 @@ lib_LTLIBRARIES = liblttng-ust-fd.la
liblttng_ust_fd_la_SOURCES = \
lttng-ust-fd.c
liblttng_ust_fd_la_LIBADD = \
$(top_builddir)/liblttng-ust/liblttng-ust.la
$(top_builddir)/liblttng-ust-comm/liblttng-ust-comm.la
if LTTNG_UST_BUILD_WITH_LIBDL
......
......@@ -106,11 +106,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_prog_javah.m4 \
$(top_srcdir)/m4/ax_sys_weak_alias.m4 \
$(top_srcdir)/m4/ax_try_compile_java.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/pprint.m4 \
$(top_srcdir)/m4/rw_prog_cxx_works.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/config/libtool.m4 \
$(top_srcdir)/config/ltoptions.m4 \
$(top_srcdir)/config/ltsugar.m4 \
$(top_srcdir)/config/ltversion.m4 \
$(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
......@@ -150,7 +152,7 @@ am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
liblttng_ust_fd_la_DEPENDENCIES = \