From 3906d953c0f89ecf24d7cf949b2499aacec7a3b6 Mon Sep 17 00:00:00 2001 From: Lars The Date: Wed, 11 Sep 2024 04:12:25 +0200 Subject: [PATCH] Fix satipc module when TEARDOWN is not correctly handled (#1187) This fixes the edge case when a new tuning call is received in the tuner when the TEARDOWN message is sended to the remote SAT>IP server but the confirmation (OK 200) is not already received. Futhermore improves a bit the logging. --- src/minisatip.c | 2 +- src/satipc.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/minisatip.c b/src/minisatip.c index 9635fe0771..d6ae6337c6 100644 --- a/src/minisatip.c +++ b/src/minisatip.c @@ -1244,7 +1244,7 @@ int read_rtsp(sockets *s) { LOG("Read RTSP (sock %d, handle %d) [%s:%d] sid %d, len: %d", s->id, s->sock, get_sockaddr_host(s->sa, ra, sizeof(ra)), get_sockaddr_port(s->sa), s->sid, rlen); - LOGM("MSG client >> process :\n%s", s->buf); + LOGM("MSG client >> process :\n%s", s->buf); //LOGM->LOG if ((s->type != TYPE_HTTP) && (strncasecmp((const char *)s->buf, "GET", 3) == 0)) { diff --git a/src/satipc.c b/src/satipc.c index b87266a61c..5c90db3f34 100644 --- a/src/satipc.c +++ b/src/satipc.c @@ -249,7 +249,7 @@ int satipc_reply(sockets *s) { if (sep) rc = map_intd(sep + 9, NULL, 0); - LOGM("MSG process << server :\n%s", s->buf); + LOGM("MSG process << server :\n%s", s->buf); //LOGM->LOG LOG("satipc_reply (adapter %d): sock %d (receiving from handle %d, state %d): " "[[ code %d ]]", s->sid, s->sock, s->id, sip->state, rc); @@ -295,8 +295,8 @@ int satipc_reply(sockets *s) { "%d", sip->id, rc); } - LOG("satipc %d, expect_reply %d, want_tune %d want commit %d", sip->id, - sip->expect_reply, sip->want_tune, sip->want_commit); + LOG("satipc %d, expect_reply %d, want_tune %d want commit %d, state %d", sip->id, + sip->expect_reply, sip->want_tune, sip->want_commit, sip->state); if (rc == 200) { if (is_transport) @@ -1270,7 +1270,7 @@ int http_request(adapter *ad, char *url, char *method, int force) { LOG("satipc_http_request (adapter %d): sock %d: [[ %s %s ]]", ad->id, remote_socket, method, url); - LOGM("MSG process >> server :\n%s", buf); + LOGM("MSG process >> server :\n%s", buf); //LOGM->LOG if (remote_socket >= 0) { sockets_write(remote_socket, buf, lb); @@ -1443,7 +1443,7 @@ int satipc_request(adapter *ad) { return 0; if ((ad->tp.freq == 0) && - ((sip->state == SATIP_STATE_OPTIONS) || + ((sip->state == SATIP_STATE_OPTIONS) || (sip->state == SATIP_STATE_INACTIVE) || (sip->state == SATIP_STATE_SETUP) || (sip->state == SATIP_STATE_PLAY))) return 0; @@ -1457,6 +1457,10 @@ int satipc_request(adapter *ad) { return 0; } + // if TEARDOWN has been recently received then re-start the session + if (sip->state == SATIP_STATE_INACTIVE && sip->last_cmd == RTSP_TEARDOWN) + sip->state = SATIP_STATE_SETUP; + // set the init parameters if (sip->state == SATIP_STATE_OPTIONS) { sip->sent_transport = 0; @@ -1474,6 +1478,7 @@ int satipc_request(adapter *ad) { sip->state = SATIP_STATE_PLAY; } + LOGM("satipc: for adapter %d, executing state %d", ad->id, sip->state); switch (sip->state) { case SATIP_STATE_OPTIONS: err = satipc_send_options(ad);