pthread_join(conn->rtp_audio_thread, NULL);
debug(2, "Audio thread terminated.");
- debug(2, "Closing timing, control and audio sockets...");
- if (conn->control_socket)
- close(conn->control_socket);
- if (conn->timing_socket)
- close(conn->timing_socket);
- if (conn->audio_socket)
- close(conn->audio_socket);
-
if (conn->outbuf) {
free(conn->outbuf);
conn->outbuf = NULL;
pthread_cleanup_push(player_thread_cleanup_handler, arg); // undo what's been done so far
-// stop looking elsewhere for DACP stuff
+ // stop looking elsewhere for DACP stuff
+ int oldState;
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState);
#ifdef CONFIG_DACP_CLIENT
// debug(1, "Set dacp server info");
// almost certainly, this has pthread cancellation points in it -- beware
conn->dapo_private_storage = mdns_dacp_monitor(conn->dacp_id);
#endif
+ pthread_setcancelstate(oldState, NULL);
// set the default volume to whaterver it was before, as stored in the config airplay_volume
debug(2, "Set initial volume to %f.", config.airplay_volume);
if (local_socket == -1)
die("Could not allocate a socket.");
- int val = 1;
- ret = setsockopt(local_socket, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
- if (ret < 0) {
- char errorstring[1024];
- strerror_r(errno, (char *)errorstring, sizeof(errorstring));
- debug(1, "Error %d: \"%s\". Couldn't set SO_REUSEADDR");
- }
+ /*
+ int val = 1;
+ ret = setsockopt(local_socket, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
+ if (ret < 0) {
+ char errorstring[1024];
+ strerror_r(errno, (char *)errorstring, sizeof(errorstring));
+ debug(1, "Error %d: \"%s\". Couldn't set SO_REUSEADDR");
+ }
+ */
SOCKADDR myaddr;
int tryCount = 0;
int msg_size = -1;
while (msg_size < 0) {
- fd_set readfds;
- FD_ZERO(&readfds);
- FD_SET(conn->fd, &readfds);
- do {
- memory_barrier();
- } while (conn->stop == 0 &&
- pselect(conn->fd + 1, &readfds, NULL, NULL, NULL, &pselect_sigset) <= 0);
+ /*
+fd_set readfds;
+FD_ZERO(&readfds);
+FD_SET(conn->fd, &readfds);
+do {
+ memory_barrier();
+} while (conn->stop == 0 &&
+ pselect(conn->fd + 1, &readfds, NULL, NULL, NULL, &pselect_sigset) <= 0);
+*/
if (conn->stop != 0) {
debug(3, "RTSP conversation thread %d shutdown requested.", conn->connection_number);
reply = rtsp_read_request_response_immediate_shutdown_requested;
goto shutdown;
}
+
nread = read(conn->fd, buf + inbuf, buflen - inbuf);
if (nread == 0) {
warning_message_sent = 1;
}
}
+
+ /*
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(conn->fd, &readfds);
memory_barrier();
} while (conn->stop == 0 &&
pselect(conn->fd + 1, &readfds, NULL, NULL, NULL, &pselect_sigset) <= 0);
+ */
+
if (conn->stop != 0) {
debug(1, "RTSP shutdown requested.");
reply = rtsp_read_request_response_immediate_shutdown_requested;
if (conn->player_thread)
player_stop(conn);
+ debug(3, "Closing timing, control and audio sockets...");
+ if (conn->control_socket)
+ close(conn->control_socket);
+ if (conn->timing_socket)
+ close(conn->timing_socket);
+ if (conn->audio_socket)
+ close(conn->audio_socket);
+
if (conn->fd > 0) {
debug(3, "Connection %d: closing fd %d.", conn->connection_number, conn->fd);
close(conn->fd);
// conn->thread = rtsp_conversation_thread;
// conn->stop = 0; // record's memory has been zeroed
// conn->authorized = 0; // record's memory has been zeroed
- fcntl(conn->fd, F_SETFL, O_NONBLOCK);
+ // fcntl(conn->fd, F_SETFL, O_NONBLOCK);
ret = pthread_create(&conn->thread, NULL, rtsp_conversation_thread_func,
conn); // also acts as a memory barrier