mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-25 04:05:40 +03:00
53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
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 */
|