mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-19 05:22:21 +02:00
fix(modem): Fix LoadProhibited after failed CMUX initialization (IDFGH-10845)
This commit is contained in:
@ -125,7 +125,8 @@ private:
|
|||||||
static const size_t GOT_LINE = SignalGroup::bit0; /*!< Bit indicating response available */
|
static const size_t GOT_LINE = SignalGroup::bit0; /*!< Bit indicating response available */
|
||||||
|
|
||||||
[[nodiscard]] bool setup_cmux(); /*!< Internal setup of CMUX mode */
|
[[nodiscard]] bool setup_cmux(); /*!< Internal setup of CMUX mode */
|
||||||
[[nodiscard]] bool exit_cmux(); /*!< Exit of CMUX mode */
|
[[nodiscard]] bool exit_cmux(); /*!< Exit of CMUX mode and cleanup */
|
||||||
|
void exit_cmux_internal(); /*!< Cleanup CMUX */
|
||||||
|
|
||||||
Lock internal_lock{}; /*!< Locks DTE operations */
|
Lock internal_lock{}; /*!< Locks DTE operations */
|
||||||
unique_buffer buffer; /*!< DTE buffer */
|
unique_buffer buffer; /*!< DTE buffer */
|
||||||
|
@ -76,12 +76,21 @@ bool DTE::exit_cmux()
|
|||||||
if (!cmux_term->deinit()) {
|
if (!cmux_term->deinit()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
exit_cmux_internal();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DTE::exit_cmux_internal()
|
||||||
|
{
|
||||||
|
if (!cmux_term) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto ejected = cmux_term->detach();
|
auto ejected = cmux_term->detach();
|
||||||
// return the ejected terminal and buffer back to this DTE
|
// return the ejected terminal and buffer back to this DTE
|
||||||
primary_term = std::move(ejected.first);
|
primary_term = std::move(ejected.first);
|
||||||
buffer = std::move(ejected.second);
|
buffer = std::move(ejected.second);
|
||||||
secondary_term = primary_term;
|
secondary_term = primary_term;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DTE::setup_cmux()
|
bool DTE::setup_cmux()
|
||||||
@ -90,14 +99,21 @@ bool DTE::setup_cmux()
|
|||||||
if (cmux_term == nullptr) {
|
if (cmux_term == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmux_term->init()) {
|
if (!cmux_term->init()) {
|
||||||
|
exit_cmux_internal();
|
||||||
|
cmux_term = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
primary_term = std::make_unique<CMuxInstance>(cmux_term, 0);
|
|
||||||
if (primary_term == nullptr) {
|
primary_term = std::make_unique<CMuxInstance>(cmux_term, 0);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
secondary_term = std::make_unique<CMuxInstance>(cmux_term, 1);
|
secondary_term = std::make_unique<CMuxInstance>(cmux_term, 1);
|
||||||
|
if (primary_term == nullptr || secondary_term == nullptr) {
|
||||||
|
exit_cmux_internal();
|
||||||
|
cmux_term = nullptr;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user