mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
join threads before closing sockets when stopping
fix for historical (minor) errors in RPiPlay from a mis-transcription of changes in upstream AirplayServer
This commit is contained in:
@@ -457,13 +457,13 @@ raop_ntp_stop(raop_ntp_t *raop_ntp)
|
||||
COND_SIGNAL(raop_ntp->wait_cond);
|
||||
MUTEX_UNLOCK(raop_ntp->wait_mutex);
|
||||
|
||||
THREAD_JOIN(raop_ntp->thread);
|
||||
|
||||
if (raop_ntp->tsock != -1) {
|
||||
closesocket(raop_ntp->tsock);
|
||||
raop_ntp->tsock = -1;
|
||||
}
|
||||
|
||||
THREAD_JOIN(raop_ntp->thread);
|
||||
|
||||
logger_log(raop_ntp->logger, LOGGER_DEBUG, "raop_ntp stopped time thread");
|
||||
|
||||
/* Mark thread as joined */
|
||||
|
||||
@@ -457,7 +457,9 @@ raop_rtp_thread_udp(void *arg)
|
||||
/* Timeout happened */
|
||||
continue;
|
||||
} else if (ret == -1) {
|
||||
logger_log(raop_rtp->logger, LOGGER_ERR, "raop_rtp error in select");
|
||||
int sock_err = SOCKET_GET_ERROR();
|
||||
logger_log(raop_rtp->logger, LOGGER_ERR,
|
||||
"raop_rtp error in select %d %s", sock_err, SOCKET_ERROR_STRING(sock_err));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -832,8 +834,14 @@ raop_rtp_stop(raop_rtp_t *raop_rtp)
|
||||
/* Join the thread */
|
||||
THREAD_JOIN(raop_rtp->thread);
|
||||
|
||||
if (raop_rtp->csock != -1) closesocket(raop_rtp->csock);
|
||||
if (raop_rtp->dsock != -1) closesocket(raop_rtp->dsock);
|
||||
if (raop_rtp->csock != -1) {
|
||||
closesocket(raop_rtp->csock);
|
||||
raop_rtp->csock = -1;
|
||||
}
|
||||
if (raop_rtp->dsock != -1) {
|
||||
closesocket(raop_rtp->dsock);
|
||||
raop_rtp->dsock = -1;
|
||||
}
|
||||
|
||||
/* Flush buffer into initial state */
|
||||
raop_buffer_flush(raop_rtp->buffer, -1);
|
||||
|
||||
@@ -233,7 +233,9 @@ raop_rtp_mirror_thread(void *arg)
|
||||
/* Timeout happened */
|
||||
continue;
|
||||
} else if (ret == -1) {
|
||||
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror error in select");
|
||||
int sock_err = SOCKET_GET_ERROR();
|
||||
logger_log(raop_rtp_mirror->logger, LOGGER_ERR,
|
||||
"raop_rtp_mirror error in select %d %s", sock_err, SOCKET_ERROR_STRING(sock_err));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -904,14 +906,14 @@ void raop_rtp_mirror_stop(raop_rtp_mirror_t *raop_rtp_mirror) {
|
||||
raop_rtp_mirror->running = 0;
|
||||
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
|
||||
|
||||
/* Join the thread */
|
||||
THREAD_JOIN(raop_rtp_mirror->thread_mirror);
|
||||
|
||||
if (raop_rtp_mirror->mirror_data_sock != -1) {
|
||||
closesocket(raop_rtp_mirror->mirror_data_sock);
|
||||
raop_rtp_mirror->mirror_data_sock = -1;
|
||||
}
|
||||
|
||||
/* Join the thread */
|
||||
THREAD_JOIN(raop_rtp_mirror->thread_mirror);
|
||||
|
||||
/* Mark thread as joined */
|
||||
MUTEX_LOCK(raop_rtp_mirror->run_mutex);
|
||||
raop_rtp_mirror->joined = 1;
|
||||
|
||||
Reference in New Issue
Block a user