1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-24 00:26:13 +01:00

Compare commits

..

No commits in common. "6cdde5d3c615715df651f89d0664249be492f0b3" and "fdf626947731f2af91143aeb9cae779d0db5efd7" have entirely different histories.

2 changed files with 36 additions and 38 deletions

View File

@ -213,25 +213,22 @@ void EthernetInterface::loop2() {
if (client) if (client)
{ {
byte socket; byte socket;
bool sockfound = false; for (socket = 0; socket < MAX_SOCK_NUM; socket++)
for (socket = 0; socket < MAX_SOCK_NUM; socket++) { {
if (clients[socket] && (clients[socket] == client)) { if (clients[socket]) {
sockfound = true; if (clients[socket] == client)
if (Diag::ETHERNET) DIAG(F("Ethernet: Old client socket %d"),socket);
break; break;
} }
} else //if (!clients[socket])
if (!sockfound) { // new client {
for (socket = 0; socket < MAX_SOCK_NUM; socket++) { if (Diag::ETHERNET) DIAG(F("Ethernet: New client "));
if (!clients[socket]) {
// On accept() the EthernetServer doesn't track the client anymore // On accept() the EthernetServer doesn't track the client anymore
// so we store it in our client array // so we store it in our client array
if (Diag::ETHERNET) DIAG(F("Socket %d"),socket);
clients[socket] = client; clients[socket] = client;
if (Diag::ETHERNET) DIAG(F("Ethernet: New client socket %d"),socket);
break; break;
} }
} }
}
if (socket==MAX_SOCK_NUM) DIAG(F("new Ethernet OVERFLOW")); if (socket==MAX_SOCK_NUM) DIAG(F("new Ethernet OVERFLOW"));
} }
@ -239,14 +236,6 @@ void EthernetInterface::loop2() {
for (byte socket = 0; socket < MAX_SOCK_NUM; socket++) for (byte socket = 0; socket < MAX_SOCK_NUM; socket++)
{ {
if (clients[socket]) { if (clients[socket]) {
if (!clients[socket].connected()) { // stop any clients which disconnect
CommandDistributor::forget(socket);
clients[socket].stop();
clients[socket]=NULL;
//if (Diag::ETHERNET)
DIAG(F("Ethernet: disconnect %d "), socket);
return; // Trick: So that we do not continue in this loop with client that is NULL
}
int available=clients[socket].available(); int available=clients[socket].available();
if (available > 0) { if (available > 0) {
@ -262,6 +251,15 @@ void EthernetInterface::loop2() {
} }
} }
// stop any clients which disconnect
for (int socket = 0; socket<MAX_SOCK_NUM; socket++) {
if (clients[socket] && !clients[socket].connected()) {
clients[socket].stop();
CommandDistributor::forget(socket);
if (Diag::ETHERNET) DIAG(F("Ethernet: disconnect %d "), socket);
}
}
WiThrottle::loop(outboundRing); WiThrottle::loop(outboundRing);
// handle at most 1 outbound transmission // handle at most 1 outbound transmission

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-stm32EC 202401280047Z" #define GITHUB_SHA "devel-202401202116Z"