Fix udp sent metric

was only incrementing by 1 for each packet sent
This commit is contained in:
Grant Limberg 2023-05-31 13:25:30 -07:00
parent f42841a6ab
commit 8ebe2c563a
No known key found for this signature in database
GPG Key ID: 8F2F97D3BE8D7735

View File

@ -453,15 +453,33 @@ public:
inline bool udpSend(PhySocket *sock,const struct sockaddr *remoteAddress,const void *data,unsigned long len)
{
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
bool sent = false;
#if defined(_WIN32) || defined(_WIN64)
int sent = ((long)::sendto(sws.sock,reinterpret_cast<const char *>(data),len,0,remoteAddress,(remoteAddress->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)) == (long)len);
Metrics::udp_send += sent;
return sent;
sent = ((long)::sendto(
sws.sock,
reinterpret_cast<const char *>(data),
len,
0,
remoteAddress,
(remoteAddress->sa_family == AF_INET6) ?
sizeof(struct sockaddr_in6) :
sizeof(struct sockaddr_in)) == (long)len);
#else
ssize_t sent = ((long)::sendto(sws.sock,data,len,0,remoteAddress,(remoteAddress->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)) == (long)len);
Metrics::udp_send += sent;
return sent;
sent = ((long)::sendto(
sws.sock,
data,
len,
0,
remoteAddress,
(remoteAddress->sa_family == AF_INET6) ?
sizeof(struct sockaddr_in6) :
sizeof(struct sockaddr_in)) == (long)len);
#endif
if (sent) {
Metrics::udp_send += len;
}
return sent;
}
#ifdef __UNIX_LIKE__