mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Fix udp sent metric
was only incrementing by 1 for each packet sent
This commit is contained in:
parent
f42841a6ab
commit
8ebe2c563a
1 changed files with 24 additions and 6 deletions
|
@ -453,15 +453,33 @@ public:
|
||||||
inline bool udpSend(PhySocket *sock,const struct sockaddr *remoteAddress,const void *data,unsigned long len)
|
inline bool udpSend(PhySocket *sock,const struct sockaddr *remoteAddress,const void *data,unsigned long len)
|
||||||
{
|
{
|
||||||
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
|
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
|
||||||
|
bool sent = false;
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#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);
|
sent = ((long)::sendto(
|
||||||
Metrics::udp_send += sent;
|
sws.sock,
|
||||||
return sent;
|
reinterpret_cast<const char *>(data),
|
||||||
|
len,
|
||||||
|
0,
|
||||||
|
remoteAddress,
|
||||||
|
(remoteAddress->sa_family == AF_INET6) ?
|
||||||
|
sizeof(struct sockaddr_in6) :
|
||||||
|
sizeof(struct sockaddr_in)) == (long)len);
|
||||||
#else
|
#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);
|
sent = ((long)::sendto(
|
||||||
Metrics::udp_send += sent;
|
sws.sock,
|
||||||
return sent;
|
data,
|
||||||
|
len,
|
||||||
|
0,
|
||||||
|
remoteAddress,
|
||||||
|
(remoteAddress->sa_family == AF_INET6) ?
|
||||||
|
sizeof(struct sockaddr_in6) :
|
||||||
|
sizeof(struct sockaddr_in)) == (long)len);
|
||||||
#endif
|
#endif
|
||||||
|
if (sent) {
|
||||||
|
Metrics::udp_send += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __UNIX_LIKE__
|
#ifdef __UNIX_LIKE__
|
||||||
|
|
Loading…
Add table
Reference in a new issue