summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--src/input/input_rtp.c4
-rw-r--r--src/xine-engine/Makefile.am2
-rw-r--r--src/xine-engine/broadcaster.c4
-rw-r--r--src/xine-engine/xine_internal.h1
-rw-r--r--src/xine-engine/xine_private.h39
-rw-r--r--src/xine-utils/attributes.h9
-rw-r--r--src/xine-utils/utils.c21
8 files changed, 72 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac
index ffadce496..c449de3c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2299,6 +2299,10 @@ CC_ATTRIBUTE_VISIBILITY([protected], [visibility_export="protected"],
[CC_ATTRIBUTE_VISIBILITY([default], [visibility_export="default"])]
)
+CC_ATTRIBUTE_VISIBILITY([internal], [visibility_export="internal"],
+ [CC_ATTRIBUTE_VISIBILITY([default], [visibility_export="default"])]
+)
+
if test "x$visibility_export" != "x"; then
CC_FLAG_VISIBILITY([
AC_DEFINE([EXPORTED], [__attribute__((visibility("default")))],
diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c
index e91e43f55..a7102fccd 100644
--- a/src/input/input_rtp.c
+++ b/src/input/input_rtp.c
@@ -171,7 +171,7 @@ typedef struct {
static int host_connect_attempt(struct in_addr ia, int port,
const char *interface,
xine_t *xine) {
- int s=socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ int s = xine_socket_cloexec(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
union {
struct sockaddr_in in;
struct sockaddr sa;
@@ -180,7 +180,7 @@ static int host_connect_attempt(struct in_addr ia, int port,
int multicast = 0; /* boolean, assume unicast */
if(s == -1) {
- LOG_MSG(xine, _("socket(): %s.\n"), strerror(errno));
+ LOG_MSG(xine, _("xine_socket_cloexec(): %s.\n"), strerror(errno));
return -1;
}
diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am
index 576c61b14..67ae63fae 100644
--- a/src/xine-engine/Makefile.am
+++ b/src/xine-engine/Makefile.am
@@ -41,7 +41,7 @@ xineinclude_HEADERS = buffer.h metronom.h configfile.h vo_scale.h \
plugin_catalog.h audio_decoder.h video_decoder.h post.h \
io_helper.h broadcaster.h info_helper.h refcounter.h alphablend.h
-noinst_HEADERS = bswap.h ffmpeg_bswap.h
+noinst_HEADERS = bswap.h ffmpeg_bswap.h xine_private.h
if WIN32
install-exec-local:
diff --git a/src/xine-engine/broadcaster.c b/src/xine-engine/broadcaster.c
index a554337a3..3f943171f 100644
--- a/src/xine-engine/broadcaster.c
+++ b/src/xine-engine/broadcaster.c
@@ -227,6 +227,8 @@ static void *manager_loop (void *this_gen) {
ssock = accept(this->msock, &(fsin.sa), &alen);
if (ssock >= 0) {
+ _x_set_socket_close_on_exec(ssock);
+
/* identification string, helps demuxer probing */
if( sock_string_write(this->stream->xine, ssock,"master xine v1") > 0 ) {
int *psock = malloc(sizeof(int));
@@ -307,7 +309,7 @@ broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port)
} servAddr;
int msock, err;
- msock = socket(PF_INET, SOCK_STREAM, 0);
+ msock = xine_socket_cloexec(PF_INET, SOCK_STREAM, 0);
if( msock < 0 )
{
xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "broadcaster: error opening master socket.\n");
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 7566c83e0..bb2113831 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.h
@@ -48,6 +48,7 @@ extern "C" {
# include "io_helper.h"
# include "info_helper.h"
# include "alphablend.h"
+# include "xine_private.h"
#else
# include <xine.h>
# include <xine/refcounter.h>
diff --git a/src/xine-engine/xine_private.h b/src/xine-engine/xine_private.h
new file mode 100644
index 000000000..1f3564cbc
--- /dev/null
+++ b/src/xine-engine/xine_private.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2000-2011 the xine project
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#ifndef HAVE_XINE_PRIVATE_H
+#define HAVE_XINE_PRIVATE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * make file descriptors and sockets uninheritable
+ */
+int _x_set_file_close_on_exec(int fd) XINE_INTERNAL;
+
+int _x_set_socket_close_on_exec(int s) XINE_INTERNAL;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h
index 2326dab18..9f02d9b7b 100644
--- a/src/xine-utils/attributes.h
+++ b/src/xine-utils/attributes.h
@@ -66,6 +66,15 @@
# define XINE_PROTECTED
#endif
+/* Export hidden only for private/internal libxine functions */
+#if defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY_INTERNAL)
+# define XINE_INTERNAL __attribute__((__visibility__("internal")))
+#elif defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT)
+# define XINE_INTERNAL __attribute__((__visibility__("default")))
+#else
+# define XINE_INTERNAL
+#endif
+
#ifdef SUPPORT_ATTRIBUTE_SENTINEL
# define XINE_SENTINEL __attribute__((__sentinel__))
#else
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c
index 25e8cc2b0..70c600b96 100644
--- a/src/xine-utils/utils.c
+++ b/src/xine-utils/utils.c
@@ -706,7 +706,7 @@ char *xine_strcat_realloc (char **dest, char *append)
}
-static int set_close_on_execute(int fd)
+int _x_set_file_close_on_exec(int fd)
{
#ifndef WIN32
return fcntl(fd, F_SETFD, FD_CLOEXEC);
@@ -715,13 +715,22 @@ static int set_close_on_execute(int fd)
#endif
}
+int _x_set_socket_close_on_exec(int s)
+{
+#ifndef WIN32
+ return fcntl(s, F_SETFD, FD_CLOEXEC);
+#else
+ return SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0);
+#endif
+}
+
int xine_open_cloexec(const char *name, int flags)
{
int fd = open(name, (flags | O_CLOEXEC));
if (fd >= 0) {
- set_close_on_execute(fd);
+ _x_set_file_close_on_exec(fd);
}
return fd;
@@ -732,7 +741,7 @@ int xine_create_cloexec(const char *name, int flags, mode_t mode)
int fd = open(name, (flags | O_CREAT | O_CLOEXEC), mode);
if (fd >= 0) {
- set_close_on_execute(fd);
+ _x_set_file_close_on_exec(fd);
}
return fd;
@@ -743,11 +752,7 @@ int xine_socket_cloexec(int domain, int type, int protocol)
int s = socket(domain, type, protocol);
if (s >= 0) {
-#ifndef WIN32
- fcntl(s, F_SETFD, FD_CLOEXEC);
-#else
- SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0);
-#endif
+ _x_set_socket_close_on_exec(s);
}
return s;