mtp: Create a method for a link failure to restart the link.
Make sure that a failed link will be restarted by calling the
reset method which should take the link down.
diff --git a/src/link_udp.c b/src/link_udp.c
index 9a7d645..7e0b94b 100644
--- a/src/link_udp.c
+++ b/src/link_udp.c
@@ -91,12 +91,11 @@
if (hdr->data_type == UDP_DATA_RETR_COMPL || hdr->data_type == UDP_DATA_RETR_IMPOS) {
LOGP(DINP, LOGL_ERROR, "Link retrieval done. Restarting the link.\n");
- mtp_link_down(link);
- mtp_link_up(link);
+ mtp_link_failure(link);
goto exit;
} else if (hdr->data_type > UDP_DATA_MSU_PRIO_3) {
LOGP(DINP, LOGL_ERROR, "Link failure. retrieved message.\n");
- mtp_link_down(link);
+ mtp_link_failure(link);
goto exit;
}
diff --git a/src/mtp_link.c b/src/mtp_link.c
index 20f4785..5423b33 100644
--- a/src/mtp_link.c
+++ b/src/mtp_link.c
@@ -78,7 +78,7 @@
} else {
LOGP(DINP, LOGL_ERROR, "Two missing SLTAs. Restart link: %p\n", link);
bsc_del_timer(&link->t2_timer);
- link->reset(link);
+ mtp_link_failure(link);
}
}
@@ -148,3 +148,9 @@
return 0;
}
+
+void mtp_link_failure(struct mtp_link *link)
+{
+ LOGP(DINP, LOGL_ERROR, "Link has failed. Resetting it: 0x%p\n", link);
+ link->reset(link);
+}