From b10b49bd6b092c5f4c4d1f47f939ff9c37269d88 Mon Sep 17 00:00:00 2001 From: Cary Sandvig Date: Thu, 22 Dec 2022 14:57:31 -0500 Subject: [PATCH] fix SocketStream::flush() covariant --- .../src/distributed/cConnectionRepository.cxx | 3 ++- panda/src/downloader/socketStream.I | 18 +++++++++--------- panda/src/downloader/socketStream.h | 6 +++--- panda/src/recorder/socketStreamRecorder.I | 3 ++- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index 73f472cb86..970c09c108 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -580,7 +580,8 @@ flush() { #ifdef HAVE_OPENSSL if (_http_conn) { - return _http_conn->flush(); + _http_conn->flush(); + return !_http_conn->is_closed(); } #endif // HAVE_OPENSSL diff --git a/panda/src/downloader/socketStream.I b/panda/src/downloader/socketStream.I index 800ed89499..fcfed2b34d 100644 --- a/panda/src/downloader/socketStream.I +++ b/panda/src/downloader/socketStream.I @@ -131,15 +131,16 @@ get_tcp_header_size() const { INLINE bool SSWriter:: consider_flush() { if (!_collect_tcp) { - return flush(); - + flush(); + return !is_closed(); } else { double elapsed = TrueClock::get_global_ptr()->get_short_time() - _queued_data_start; // If the elapsed time is negative, someone must have reset the clock // back, so just go ahead and flush. if (elapsed < 0.0 || elapsed >= _collect_tcp_interval) { - return flush(); + flush(); + return !is_closed(); } } @@ -150,11 +151,10 @@ consider_flush() { * Sends the most recently queued data now. This only has meaning if * set_collect_tcp() has been set to true. */ -INLINE bool SSWriter:: +INLINE void SSWriter:: flush() { _ostream->flush(); _queued_data_start = TrueClock::get_global_ptr()->get_short_time(); - return !is_closed(); } /** @@ -176,9 +176,9 @@ OSocketStream(std::streambuf *buf) : std::ostream(buf), SSWriter(this) { * Sends the most recently queued data now. This only has meaning if * set_collect_tcp() has been set to true. */ -INLINE bool OSocketStream:: +INLINE void OSocketStream:: flush() { - return SSWriter::flush(); + SSWriter::flush(); } /** @@ -212,7 +212,7 @@ get_tcp_header_size() const { * Sends the most recently queued data now. This only has meaning if * set_collect_tcp() has been set to true. */ -INLINE bool SocketStream:: +INLINE void SocketStream:: flush() { - return SSWriter::flush(); + SSWriter::flush(); } diff --git a/panda/src/downloader/socketStream.h b/panda/src/downloader/socketStream.h index 6d52e0e79a..98a26810eb 100644 --- a/panda/src/downloader/socketStream.h +++ b/panda/src/downloader/socketStream.h @@ -106,7 +106,7 @@ PUBLISHED: INLINE int get_tcp_header_size() const; INLINE bool consider_flush(); - INLINE bool flush(); + INLINE void flush(); private: std::ostream *_ostream; @@ -168,7 +168,7 @@ PUBLISHED: virtual bool is_closed() = 0; virtual void close() = 0; - INLINE bool flush(); + INLINE void flush(); }; /** @@ -190,7 +190,7 @@ PUBLISHED: INLINE void set_tcp_header_size(int tcp_header_size); INLINE int get_tcp_header_size() const; - INLINE bool flush(); + INLINE void flush(); }; diff --git a/panda/src/recorder/socketStreamRecorder.I b/panda/src/recorder/socketStreamRecorder.I index 520e6f5d40..998ec95d7b 100644 --- a/panda/src/recorder/socketStreamRecorder.I +++ b/panda/src/recorder/socketStreamRecorder.I @@ -135,7 +135,8 @@ consider_flush() { INLINE bool SocketStreamRecorder:: flush() { if (_stream != nullptr) { - return _stream->flush(); + _stream->flush(); + return !_stream->is_closed(); } return true; }