aboutsummaryrefslogtreecommitdiffstats
path: root/testing/motion/pthread_key_create.patch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/motion/pthread_key_create.patch')
-rw-r--r--testing/motion/pthread_key_create.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/motion/pthread_key_create.patch b/testing/motion/pthread_key_create.patch
new file mode 100644
index 0000000000..afedce75b5
--- /dev/null
+++ b/testing/motion/pthread_key_create.patch
@@ -0,0 +1,53 @@
+make sure we create the tls key before we access in any way.
+
+we also fix the check for broken glibc strerror_r
+
+--- ./motion.c.orig
++++ ./motion.c
+@@ -2267,6 +2267,9 @@
+ struct sigaction sigchild_action;
+ setup_signals(&sig_handler_action, &sigchild_action);
+
++ /* Create the TLS key for thread number. */
++ pthread_key_create(&tls_key_threadnr, NULL);
++
+ motion_startup(1, argc, argv);
+
+ #ifdef HAVE_FFMPEG
+@@ -2290,9 +2293,6 @@
+ pthread_attr_init(&thread_attr);
+ pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
+
+- /* Create the TLS key for thread number. */
+- pthread_key_create(&tls_key_threadnr, NULL);
+-
+ do {
+ if (restart) {
+ /* Handle the restart situation. Currently the approach is to
+@@ -2745,9 +2745,6 @@
+ {
+ int errno_save, n;
+ char buf[1024];
+-#if (!defined(BSD)) && (!(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)
+- char msg_buf[100];
+-#endif
+ va_list ap;
+ int threadnr;
+
+@@ -2780,12 +2778,13 @@
+ * version of strerror_r, which doesn't actually put the message into
+ * my buffer :-(. I have put in a 'hack' to get around this.
+ */
+-#if (defined(BSD))
+- strerror_r(errno_save, buf + n, sizeof(buf) - n); /* 2 for the ': ' */
+-#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
++#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! defined(_GNU_SOURCE))
+ strerror_r(errno_save, buf + n, sizeof(buf) - n);
+ #else
++ {
++ char msg_buf[100];
+ strncat(buf, strerror_r(errno_save, msg_buf, sizeof(msg_buf)), 1024 - strlen(buf));
++ }
+ #endif
+ }
+ /* If 'level' is not negative, send the message to the syslog */