Skip to content

Commit a061442

Browse files
abort connection on accept if _tcp_accept failed (#22)
* abort connection on accept if _tcp_accept failed * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 3293f35 commit a061442

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/AsyncTCP.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,20 +1618,19 @@ void AsyncServer::end() {
16181618
int8_t AsyncServer::_accept(tcp_pcb *pcb, int8_t err) {
16191619
// ets_printf("+A: 0x%08x\n", pcb);
16201620
if (_connect_cb) {
1621-
AsyncClient *c = new AsyncClient(pcb);
1621+
AsyncClient *c = new (std::nothrow) AsyncClient(pcb);
16221622
if (c) {
16231623
c->setNoDelay(_noDelay);
16241624
const int8_t err = _tcp_accept(this, c);
16251625
if (err != ERR_OK) {
1626+
tcp_abort(pcb);
16261627
delete c;
16271628
}
16281629
return err;
16291630
}
16301631
}
1631-
if (tcp_close(pcb) != ERR_OK) {
1632-
tcp_abort(pcb);
1633-
}
1634-
log_d("FAIL");
1632+
tcp_abort(pcb);
1633+
log_d("_accept failed");
16351634
return ERR_OK;
16361635
}
16371636

0 commit comments

Comments
 (0)