Skip to content

Commit

Permalink
Fix satipc module when TEARDOWN is not correctly handled (#1187)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lars18th authored Sep 11, 2024
1 parent 226b311 commit 3906d95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/minisatip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
15 changes: 10 additions & 5 deletions src/satipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 3906d95

Please sign in to comment.