Add index numbers for each RTSP conversation thread, to help figure debug messages out better.

This commit is contained in:
Mike Brady
2017-08-21 18:08:41 +02:00
parent 98155b00d1
commit abd342553a
3 changed files with 15 additions and 6 deletions
+1
View File
@@ -52,6 +52,7 @@ typedef struct {
} stream_cfg;
typedef struct {
int connection_number; // for debug ID purposes, nothing else...
int fd;
int authorized; // set if a password is required and has been supplied
stream_cfg stream;
+3
View File
@@ -713,6 +713,9 @@ void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time,
pthread_mutex_lock(&conn->reference_time_mutex);
*timestamp = conn->reference_timestamp;
*timestamp_time = conn->reference_timestamp_time;
if ((*timestamp == 0) && (*timestamp_time == 0)) {
debug(1,"Reference timestamp is invalid.");
}
*remote_timestamp_time = conn->remote_reference_timestamp_time;
pthread_mutex_unlock(&conn->reference_time_mutex);
}
+11 -6
View File
@@ -96,6 +96,8 @@ static rtsp_conn_info *playing_conn =
NULL; // the data structure representing the connection that has the player.
static rtsp_conn_info **conns = NULL;
int RTSP_connection_index = 0;
void memory_barrier() {
pthread_mutex_lock(&barrier_mutex);
pthread_mutex_unlock(&barrier_mutex);
@@ -1771,11 +1773,12 @@ static void *rtsp_conversation_thread_func(void *pconn) {
char *hdr, *auth_nonce = NULL;
enum rtsp_read_request_response reply;
conn->running = 1;
do {
reply = rtsp_read_request(conn, &req);
if (reply == rtsp_read_request_response_ok) {
debug(3, "RTSP Packet received of type \"%s\":", req->method),
debug(3, "RTSP thread %d received an RTSP Packet of type \"%s\":",conn->connection_number, req->method),
debug_print_msg_headers(3, req);
resp = msg_init();
resp->respcode = 400;
@@ -1812,7 +1815,7 @@ static void *rtsp_conversation_thread_func(void *pconn) {
}
} while (reply != rtsp_read_request_response_shutdown_requested);
debug(1, "Closing down RTSP conversation thread...");
debug(1, "Closing down RTSP conversation thread %d...",conn->connection_number);
if (rtsp_playing()) {
player_stop(&conn->player_thread, conn); // might be less noisy doing this first
rtp_shutdown(conn);
@@ -1831,7 +1834,7 @@ static void *rtsp_conversation_thread_func(void *pconn) {
// "close RTSP connection.");
// }
rtp_terminate(conn);
debug(2, "RTSP conversation thread terminated.");
debug(2, "RTSP conversation thread %d terminated.",conn->connection_number);
// please_shutdown = 0;
return NULL;
}
@@ -1979,6 +1982,7 @@ void rtsp_listen_loop(void) {
if (conn == 0)
die("Couldn't allocate memory for an rtsp_conn_info record.");
memset(conn, 0, sizeof(rtsp_conn_info));
conn->connection_number = RTSP_connection_index++;
socklen_t slen = sizeof(conn->remote);
conn->fd = accept(acceptfd, (struct sockaddr *)&conn->remote, &slen);
@@ -2040,11 +2044,12 @@ void rtsp_listen_loop(void) {
// conn->thread = rtsp_conversation_thread;
// conn->stop = 0; // record's memory has been zeroed
// conn->authorized = 0; // record's memory has been zeroed
conn->running = 1;
ret = pthread_create(&conn->thread, NULL, rtsp_conversation_thread_func,
conn); // also acts as a memory barrier
if (ret)
die("Failed to create RTSP receiver thread!");
die("Failed to create RTSP receiver thread %d!",conn->connection_number);
debug(1,"Successfully created RTSP receiver thread %d.",conn->connection_number);
track_thread(conn);
}
}