Shutdown sockets on connection close
This commit is contained in:
@@ -150,6 +150,14 @@ void wivrn::wivrn_connection::reset(TCP && tcp)
|
||||
init();
|
||||
}
|
||||
|
||||
void wivrn::wivrn_connection::shutdown()
|
||||
{
|
||||
if (stream)
|
||||
::shutdown(stream.get_fd(), SHUT_RDWR);
|
||||
if (control)
|
||||
::shutdown(control.get_fd(), SHUT_RDWR);
|
||||
}
|
||||
|
||||
std::optional<wivrn::from_headset::packets> wivrn::wivrn_connection::poll_control(int timeout)
|
||||
{
|
||||
pollfd fds{};
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
return active;
|
||||
}
|
||||
void reset(TCP && tcp);
|
||||
void shutdown();
|
||||
|
||||
template <typename T>
|
||||
void send_control(T && packet)
|
||||
|
||||
@@ -221,6 +221,11 @@ wivrn::wivrn_session::wivrn_session(wivrn::TCP && tcp, u_system & system) :
|
||||
roles.gamepad_profile = xdevs[roles.gamepad]->name;
|
||||
}
|
||||
|
||||
wivrn_session::~wivrn_session()
|
||||
{
|
||||
connection.shutdown();
|
||||
}
|
||||
|
||||
xrt_result_t wivrn::wivrn_session::create_session(wivrn::TCP && tcp,
|
||||
u_system & system,
|
||||
xrt_system_devices ** out_xsysd,
|
||||
|
||||
@@ -115,6 +115,8 @@ class wivrn_session : public xrt_system_devices
|
||||
wivrn_session(TCP && tcp, u_system &);
|
||||
|
||||
public:
|
||||
~wivrn_session();
|
||||
|
||||
static xrt_result_t create_session(TCP && tcp,
|
||||
u_system & system,
|
||||
xrt_system_devices ** out_xsysd,
|
||||
|
||||
Reference in New Issue
Block a user