Skip to content

Commit f2e20fe

Browse files
committed
udp_port: use SocketHandle type for getting uv_fileno() socket handle
1 parent 521b48a commit f2e20fe

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/internal_modules/roc_netio/target_libuv/roc_netio/udp_port.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ UdpPort::UdpPort(const UdpConfig& config,
4040
, recv_started_(false)
4141
, want_close_(false)
4242
, closed_(false)
43-
, fd_()
43+
, sock_()
4444
, packet_factory_(packet_factory)
4545
, inbound_writer_(NULL)
4646
, rate_limiter_(PacketLogInterval, 1) {
@@ -116,16 +116,15 @@ bool UdpPort::open() {
116116
return false;
117117
}
118118

119-
#ifndef __WIN32__
120-
const int fd_err = uv_fileno((uv_handle_t*)&handle_, &fd_);
119+
uv_os_fd_t tmpfd;
120+
121+
const int fd_err = uv_fileno((uv_handle_t*)&handle_, &tmpfd);
121122

122123
if (fd_err != 0) {
123124
roc_panic("udp port: %s: uv_fileno(): [%s] %s", descriptor(), uv_err_name(fd_err),
124125
uv_strerror(fd_err));
125126
}
126-
#else // __WIN32__
127-
fd_ = handle_.socket;
128-
#endif // __WIN32__
127+
sock_ = (long long unsigned int)tmpfd;
129128

130129
update_descriptor();
131130

@@ -469,7 +468,7 @@ bool UdpPort::try_nonblocking_write_(const packet::PacketPtr& pp) {
469468

470469
const packet::UDP& udp = *pp->udp();
471470
const bool success =
472-
socket_try_send_to(fd_, pp->buffer().data(), pp->buffer().size(), udp.dst_addr);
471+
socket_try_send_to(sock_, pp->buffer().data(), pp->buffer().size(), udp.dst_addr);
473472

474473
if (success) {
475474
const int packet_num = ++sent_packets_;

src/internal_modules/roc_netio/target_libuv/roc_netio/udp_port.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "roc_core/rate_limiter.h"
2323
#include "roc_netio/basic_port.h"
2424
#include "roc_netio/iclose_handler.h"
25+
#include "roc_netio/socket_ops.h"
2526
#include "roc_packet/iwriter.h"
2627
#include "roc_packet/packet_factory.h"
2728

@@ -147,7 +148,7 @@ class UdpPort : public BasicPort, private packet::IWriter {
147148
bool want_close_;
148149
bool closed_;
149150

150-
uv_os_sock_t fd_;
151+
SocketHandle sock_;
151152

152153
packet::PacketFactory& packet_factory_;
153154

0 commit comments

Comments
 (0)