From 36fd91bbeb50e33556cd5dfd73888552dd0a69d6 Mon Sep 17 00:00:00 2001 From: Alessio Igor Bogani <alessio.bogani@elettra.eu> Date: Tue, 23 Jul 2024 07:51:45 +0000 Subject: [PATCH] Close connection if Write() is executed with buffer != 0 --- src/Socket2.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Socket2.cpp b/src/Socket2.cpp index 2b6a2b8..bee4437 100644 --- a/src/Socket2.cpp +++ b/src/Socket2.cpp @@ -496,15 +496,23 @@ void Socket2::write(const Tango::DevVarCharArray *argin) { DEBUG_STREAM << "Socket2::Write() - " << device_name << std::endl; /*----- PROTECTED REGION ID(Socket2::write) ENABLED START -----*/ + vector<unsigned char> argin_data; + argin_data << *argin; + size_t bytes_total = 0, bytes_to_write = argin_data.size(); + if (! init_error.empty()) { sleep(tout); Tango::Except::throw_exception( "", init_error.c_str(), __PRETTY_FUNCTION__); } - vector<unsigned char> argin_data; - argin_data << *argin; - size_t bytes_total = 0, bytes_to_write = argin_data.size(); + if (max(output_queue_length(), 0) != 0) { + close(); + resolve(); + open(); + reconnections += 1; + goto error; + } while (bytes_total < bytes_to_write) { int s = select(WRITE); -- GitLab