summaryrefslogtreecommitdiff
path: root/src/xine-utils
diff options
context:
space:
mode:
authorChris Rankin <rankincj@yahoo.com>2011-10-03 21:07:39 +0100
committerChris Rankin <rankincj@yahoo.com>2011-10-03 21:07:39 +0100
commitfa660f82ae5889b931c645133abb151f26fba343 (patch)
tree1da8b888711c6afcf209d54f67e1c3ac43d9da9b /src/xine-utils
parent5db268a002e7a102855e84a3ff5e1c27ca7cb927 (diff)
downloadxine-lib-fa660f82ae5889b931c645133abb151f26fba343.tar.gz
xine-lib-fa660f82ae5889b931c645133abb151f26fba343.tar.bz2
Set CLOEXEC flag on three more sockets.
There are two functions that actually set this flag: int _x_set_file_close_on_exec() int _x_set_socket_close_on_exec() (We need two functions because file descriptors and sockets are not the same under WIN32 - of course). These function have been assigned "internal" visibility so that they can be used throughout libxine.so itself while still not being exported to the global symbol table. In other words, they're both as close to being "static" as I can make them.
Diffstat (limited to 'src/xine-utils')
-rw-r--r--src/xine-utils/attributes.h9
-rw-r--r--src/xine-utils/utils.c21
2 files changed, 22 insertions, 8 deletions
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;