[general] Put back support for platforms without pipe2(), see issue #239

This commit is contained in:
ejurgensen 2016-03-17 22:20:16 +01:00
parent ec43195633
commit b454a2fd60
11 changed files with 80 additions and 1 deletions

View File

@ -46,6 +46,7 @@ AC_CHECK_FUNCS(strptime)
AC_CHECK_FUNCS(strtok_r) AC_CHECK_FUNCS(strtok_r)
AC_CHECK_FUNCS(timegm) AC_CHECK_FUNCS(timegm)
AC_CHECK_FUNCS(euidaccess) AC_CHECK_FUNCS(euidaccess)
AC_CHECK_FUNCS(pipe2)
dnl Large File Support (LFS) dnl Large File Support (LFS)
AC_SYS_LARGEFILE AC_SYS_LARGEFILE

View File

@ -1796,14 +1796,22 @@ cache_init(void)
return 0; return 0;
} }
#ifdef HAVE_PIPE2
ret = pipe2(g_exit_pipe, O_CLOEXEC); ret = pipe2(g_exit_pipe, O_CLOEXEC);
#else
ret = pipe(g_exit_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_CACHE, "Could not create pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_CACHE, "Could not create exit pipe: %s\n", strerror(errno));
goto exit_fail; goto exit_fail;
} }
#ifdef HAVE_PIPE2
ret = pipe2(g_cmd_pipe, O_CLOEXEC); ret = pipe2(g_cmd_pipe, O_CLOEXEC);
#else
ret = pipe(g_cmd_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_CACHE, "Could not create command pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_CACHE, "Could not create command pipe: %s\n", strerror(errno));

View File

@ -2271,7 +2271,11 @@ filescanner_init(void)
return -1; return -1;
} }
#ifdef HAVE_PIPE2
ret = pipe2(exit_pipe, O_CLOEXEC); ret = pipe2(exit_pipe, O_CLOEXEC);
#else
ret = pipe(exit_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_FATAL, L_SCAN, "Could not create pipe: %s\n", strerror(errno)); DPRINTF(E_FATAL, L_SCAN, "Could not create pipe: %s\n", strerror(errno));
@ -2292,7 +2296,11 @@ filescanner_init(void)
goto ino_fail; goto ino_fail;
} }
#ifdef HAVE_PIPE2
ret = pipe2(cmd_pipe, O_CLOEXEC); ret = pipe2(cmd_pipe, O_CLOEXEC);
#else
ret = pipe(cmd_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_SCAN, "Could not create command pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_SCAN, "Could not create command pipe: %s\n", strerror(errno));

View File

@ -1338,7 +1338,11 @@ httpd_init(void)
exitev = event_new(evbase_httpd, exit_efd, EV_READ, exit_cb, NULL); exitev = event_new(evbase_httpd, exit_efd, EV_READ, exit_cb, NULL);
#else #else
# ifdef HAVE_PIPE2
ret = pipe2(exit_pipe, O_CLOEXEC); ret = pipe2(exit_pipe, O_CLOEXEC);
# else
ret = pipe(exit_pipe);
# endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_FATAL, L_HTTPD, "Could not create pipe: %s\n", strerror(errno)); DPRINTF(E_FATAL, L_HTTPD, "Could not create pipe: %s\n", strerror(errno));

View File

@ -2663,7 +2663,11 @@ dacp_init(void)
return -1; return -1;
} }
#else #else
# ifdef HAVE_PIPE2
ret = pipe2(update_pipe, O_CLOEXEC); ret = pipe2(update_pipe, O_CLOEXEC);
# else
ret = pipe(update_pipe);
# endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DACP, "Could not create update pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_DACP, "Could not create update pipe: %s\n", strerror(errno));

View File

@ -298,7 +298,16 @@ streaming_init(void)
} }
// Non-blocking because otherwise httpd and player thread may deadlock // Non-blocking because otherwise httpd and player thread may deadlock
#ifdef HAVE_PIPE2
ret = pipe2(streaming_pipe, O_CLOEXEC | O_NONBLOCK); ret = pipe2(streaming_pipe, O_CLOEXEC | O_NONBLOCK);
#else
if ( pipe(streaming_pipe) < 0 ||
fcntl(streaming_pipe[0], F_SETFL, O_CLOEXEC | O_NONBLOCK) < 0 ||
fcntl(streaming_pipe[1], F_SETFL, O_CLOEXEC | O_NONBLOCK) < 0 )
ret = -1;
else
ret = 0;
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_FATAL, L_STREAMING, "Could not create pipe: %s\n", strerror(errno)); DPRINTF(E_FATAL, L_STREAMING, "Could not create pipe: %s\n", strerror(errno));

View File

@ -4791,14 +4791,22 @@ int mpd_init(void)
v6enabled = cfg_getbool(cfg_getsec(cfg, "general"), "ipv6"); v6enabled = cfg_getbool(cfg_getsec(cfg, "general"), "ipv6");
#ifdef HAVE_PIPE2
ret = pipe2(g_exit_pipe, O_CLOEXEC); ret = pipe2(g_exit_pipe, O_CLOEXEC);
#else
ret = pipe(g_exit_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_MPD, "Could not create pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_MPD, "Could not create pipe: %s\n", strerror(errno));
goto exit_fail; goto exit_fail;
} }
#ifdef HAVE_PIPE2
ret = pipe2(g_cmd_pipe, O_CLOEXEC); ret = pipe2(g_cmd_pipe, O_CLOEXEC);
#else
ret = pipe(g_cmd_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_MPD, "Could not create command pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_MPD, "Could not create command pipe: %s\n", strerror(errno));

View File

@ -4655,7 +4655,11 @@ player_init(void)
goto audio_fail; goto audio_fail;
} }
#ifdef HAVE_PIPE2
ret = pipe2(exit_pipe, O_CLOEXEC); ret = pipe2(exit_pipe, O_CLOEXEC);
#else
ret = pipe(exit_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_PLAYER, "Could not create pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_PLAYER, "Could not create pipe: %s\n", strerror(errno));
@ -4663,7 +4667,11 @@ player_init(void)
goto exit_fail; goto exit_fail;
} }
#ifdef HAVE_PIPE2
ret = pipe2(cmd_pipe, O_CLOEXEC); ret = pipe2(cmd_pipe, O_CLOEXEC);
#else
ret = pipe(cmd_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_PLAYER, "Could not create command pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_PLAYER, "Could not create command pipe: %s\n", strerror(errno));

View File

@ -917,7 +917,16 @@ remote_pairing_init(void)
return -1; return -1;
} }
#else #else
# ifdef HAVE_PIPE2
ret = pipe2(pairing_pipe, O_CLOEXEC | O_NONBLOCK); ret = pipe2(pairing_pipe, O_CLOEXEC | O_NONBLOCK);
# else
if ( pipe(pairing_pipe) < 0 ||
fcntl(pairing_pipe[0], F_SETFL, O_CLOEXEC | O_NONBLOCK) < 0 ||
fcntl(pairing_pipe[1], F_SETFL, O_CLOEXEC | O_NONBLOCK) < 0 )
ret = -1;
else
ret = 0;
# endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_FATAL, L_REMOTE, "Could not create pairing pipe: %s\n", strerror(errno)); DPRINTF(E_FATAL, L_REMOTE, "Could not create pairing pipe: %s\n", strerror(errno));

View File

@ -2193,21 +2193,33 @@ spotify_init(void)
if (ret < 0) if (ret < 0)
goto assign_fail; goto assign_fail;
#ifdef HAVE_PIPE2
ret = pipe2(g_exit_pipe, O_CLOEXEC); ret = pipe2(g_exit_pipe, O_CLOEXEC);
#else
ret = pipe(g_exit_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_SPOTIFY, "Could not create pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_SPOTIFY, "Could not create pipe: %s\n", strerror(errno));
goto exit_fail; goto exit_fail;
} }
#ifdef HAVE_PIPE2
ret = pipe2(g_cmd_pipe, O_CLOEXEC); ret = pipe2(g_cmd_pipe, O_CLOEXEC);
#else
ret = pipe(g_cmd_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_SPOTIFY, "Could not create command pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_SPOTIFY, "Could not create command pipe: %s\n", strerror(errno));
goto cmd_fail; goto cmd_fail;
} }
#ifdef HAVE_PIPE2
ret = pipe2(g_notify_pipe, O_CLOEXEC); ret = pipe2(g_notify_pipe, O_CLOEXEC);
#else
ret = pipe(g_notify_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_SPOTIFY, "Could not notify command pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_SPOTIFY, "Could not notify command pipe: %s\n", strerror(errno));

View File

@ -289,14 +289,22 @@ worker_init(void)
{ {
int ret; int ret;
#ifdef HAVE_PIPE2
ret = pipe2(g_exit_pipe, O_CLOEXEC); ret = pipe2(g_exit_pipe, O_CLOEXEC);
#else
ret = pipe(g_exit_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_MAIN, "Could not create pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_MAIN, "Could not create pipe: %s\n", strerror(errno));
goto exit_fail; goto exit_fail;
} }
#ifdef HAVE_PIPE2
ret = pipe2(g_cmd_pipe, O_CLOEXEC); ret = pipe2(g_cmd_pipe, O_CLOEXEC);
#else
ret = pipe(g_cmd_pipe);
#endif
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_MAIN, "Could not create command pipe: %s\n", strerror(errno)); DPRINTF(E_LOG, L_MAIN, "Could not create command pipe: %s\n", strerror(errno));