mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-14 07:35:12 +01:00
Fix network disconnect and handle send failures
This commit is contained in:
parent
64b200cafd
commit
37ca5e562b
@ -162,6 +162,8 @@ void C64::network_vblank()
|
|||||||
remote->Disconnect();
|
remote->Disconnect();
|
||||||
delete remote;
|
delete remote;
|
||||||
this->network = NULL;
|
this->network = NULL;
|
||||||
|
TheC64->network_connection_type = NONE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ bool Network::SendUpdate(struct sockaddr_in *addr)
|
|||||||
|
|
||||||
v = this->SendTo((void*)p, this->sock,
|
v = this->SendTo((void*)p, this->sock,
|
||||||
size_to_send, addr);
|
size_to_send, addr);
|
||||||
if (v < 0 || (size_t)v != size_to_send)
|
if (v <= 0 || (size_t)v != size_to_send)
|
||||||
return false;
|
return false;
|
||||||
cur_sz += size_to_send;
|
cur_sz += size_to_send;
|
||||||
p += size_to_send;
|
p += size_to_send;
|
||||||
@ -734,6 +734,12 @@ bool Network::MarshalAllData(NetworkUpdate *ud)
|
|||||||
{
|
{
|
||||||
NetworkUpdate *p = ud;
|
NetworkUpdate *p = ud;
|
||||||
|
|
||||||
|
/* Already marshalled? */
|
||||||
|
if (ntohs(p->magic) == FRODO_NETWORK_MAGIC) {
|
||||||
|
warning("Data already marshalled\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
while (p->type != STOP)
|
while (p->type != STOP)
|
||||||
{
|
{
|
||||||
NetworkUpdate *nxt = this->GetNext(p);
|
NetworkUpdate *nxt = this->GetNext(p);
|
||||||
@ -992,8 +998,9 @@ bool Network::DecodeUpdate(C64Display *display, uint8 *js, MOS6581 *dst)
|
|||||||
/* We won't receive this, but it also doesn't really matter */
|
/* We won't receive this, but it also doesn't really matter */
|
||||||
break;
|
break;
|
||||||
case DISCONNECT:
|
case DISCONNECT:
|
||||||
out = false;
|
printf("Got disconnect\n");
|
||||||
break;
|
TheC64->network_connection_type = NONE;
|
||||||
|
return false;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1290,19 +1297,20 @@ network_connection_error_t Network::WaitForBandWidthReply()
|
|||||||
|
|
||||||
void Network::Disconnect()
|
void Network::Disconnect()
|
||||||
{
|
{
|
||||||
this->ResetNetworkUpdate();
|
printf("Disconnecting\n");
|
||||||
|
|
||||||
|
this->ResetNetworkUpdate();
|
||||||
NetworkUpdate *disconnect = InitNetworkUpdate(this->cur_ud, DISCONNECT,
|
NetworkUpdate *disconnect = InitNetworkUpdate(this->cur_ud, DISCONNECT,
|
||||||
sizeof(NetworkUpdate));
|
sizeof(NetworkUpdate));
|
||||||
|
|
||||||
/* Add a stop at the end of the update */
|
/* Add a stop at the end of the update */
|
||||||
this->AddNetworkUpdate(disconnect);
|
this->AddNetworkUpdate(disconnect);
|
||||||
this->SendServerUpdate();
|
|
||||||
this->SendPeerUpdate();
|
|
||||||
|
|
||||||
TheC64->network_connection_type = NONE;
|
this->SendPeerUpdate();
|
||||||
|
this->SendServerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Network::networking_started = false;
|
bool Network::networking_started = false;
|
||||||
|
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO)
|
||||||
|
Loading…
Reference in New Issue
Block a user