Implement server-side downgrade from udp
This commit is contained in:
@@ -125,7 +125,7 @@ static uint8_t udpsend(WuClient *client, const uint8_t *data, unsigned len, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
UdpStream::UdpStream(): OutStream(), client(NULL), total_len(0), id(0) {
|
||||
UdpStream::UdpStream(): OutStream(), client(NULL), total_len(0), id(0), failed(false) {
|
||||
ptr = data;
|
||||
end = data + UDPSTREAM_BUFSIZE;
|
||||
|
||||
@@ -137,8 +137,10 @@ void UdpStream::flush() {
|
||||
total_len += len;
|
||||
|
||||
if (client) {
|
||||
if (udpsend(client, data, len, &id))
|
||||
if (udpsend(client, data, len, &id)) {
|
||||
vlog.error("Error sending udp, client gone?");
|
||||
failed = true;
|
||||
}
|
||||
} else {
|
||||
vlog.error("Tried to send udp without a client");
|
||||
}
|
||||
@@ -151,6 +153,14 @@ void UdpStream::overrun(size_t needed) {
|
||||
abort();
|
||||
}
|
||||
|
||||
bool UdpStream::isFailed() const {
|
||||
return failed;
|
||||
}
|
||||
|
||||
void UdpStream::clearFailed() {
|
||||
failed = false;
|
||||
}
|
||||
|
||||
void wuGotHttp(const char msg[], const uint32_t msglen, char resp[]) {
|
||||
WuGotHttp(host, msg, msglen, resp);
|
||||
}
|
||||
|
||||
@@ -39,11 +39,15 @@ namespace network {
|
||||
void setClient(WuClient *cli) {
|
||||
client = cli;
|
||||
}
|
||||
|
||||
bool isFailed() const;
|
||||
void clearFailed();
|
||||
private:
|
||||
uint8_t data[UDPSTREAM_BUFSIZE];
|
||||
WuClient *client;
|
||||
size_t total_len;
|
||||
uint32_t id;
|
||||
bool failed;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user