Skip to content

Commit 2daabbf

Browse files
committed
Merge branch 'hotfix/1.28.5'
2 parents f4f960e + eb3e89e commit 2daabbf

File tree

4 files changed

+33
-41
lines changed

4 files changed

+33
-41
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.28.4
1+
1.28.5

src/eckit/net/ProxiedTCPClient.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include "eckit/net/ProxiedTCPClient.h"
1313

14-
#include "eckit/config/Resource.h"
1514
#include "eckit/net/HttpHeader.h"
1615

1716

@@ -27,7 +26,7 @@ ProxiedTCPClient::~ProxiedTCPClient() {}
2726
net::TCPSocket& ProxiedTCPClient::connect(const std::string& host, int port, int retries, int timeout) {
2827
net::TCPSocket& socket = TCPClient::connect(proxy_.hostname(), proxy_.port(), retries, timeout);
2928

30-
socket.debug(debug_);
29+
socket.debug(debug_.on);
3130

3231
const char* CRLF = "\r\n";
3332

src/eckit/net/TCPSocket.cc

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ TCPSocket::TCPSocket() :
5757
localPort_(-1),
5858
remotePort_(-1),
5959
remoteAddr_(none),
60-
localAddr_(none),
61-
debug_(false),
62-
newline_(true),
63-
mode_(0) {}
60+
localAddr_(none) {}
6461

6562
// This contructor performs a change of ownership of the socket
6663
TCPSocket::TCPSocket(net::TCPSocket& other) :
@@ -70,10 +67,7 @@ TCPSocket::TCPSocket(net::TCPSocket& other) :
7067
remoteHost_(other.remoteHost_),
7168
remoteAddr_(other.remoteAddr_),
7269
localHost_(other.localHost_),
73-
localAddr_(other.localAddr_),
74-
debug_(false),
75-
newline_(true),
76-
mode_(0) {
70+
localAddr_(other.localAddr_) {
7771
other.socket_ = -1; // Detach socket from other
7872
other.remoteAddr_ = none;
7973
other.remoteHost_ = std::string();
@@ -95,9 +89,7 @@ TCPSocket& TCPSocket::operator=(net::TCPSocket& other) {
9589
remoteHost_ = other.remoteHost_;
9690
remotePort_ = other.remotePort_;
9791

98-
debug_ = other.debug_;
99-
newline_ = other.newline_;
100-
mode_ = other.mode_;
92+
debug_ = other.debug_;
10193

10294
other.socket_ = -1; // Detach socket from other
10395

@@ -116,7 +108,7 @@ void TCPSocket::closeInput() {
116108
SYSCALL(::shutdown(socket_, SHUT_RD));
117109
}
118110

119-
long TCPSocket::write(const void* buf, long length) {
111+
long TCPSocket::write(const void* buf, long length) const {
120112

121113
// Allow zero length packets
122114
if (length == 0) {
@@ -125,20 +117,20 @@ long TCPSocket::write(const void* buf, long length) {
125117

126118
long requested = length;
127119

128-
if (debug_) {
120+
if (debug_.on) {
129121

130-
if (mode_ != 'w') {
131-
newline_ = true;
122+
if (debug_.mode != 'w') {
123+
debug_.newline = true;
132124
std::cout << std::endl
133125
<< std::endl;
134-
mode_ = 'w';
126+
debug_.mode = 'w';
135127
}
136128

137129
const char* p = reinterpret_cast<const char*>(buf);
138130
for (long i = 0; i < std::min(length, 512L); i++) {
139-
if (newline_) {
131+
if (debug_.newline) {
140132
std::cout << ">>> ";
141-
newline_ = false;
133+
debug_.newline = false;
142134
}
143135

144136
if (p[i] == '\r') {
@@ -147,7 +139,7 @@ long TCPSocket::write(const void* buf, long length) {
147139
else if (p[i] == '\n') {
148140
std::cout << "\\n"
149141
<< std::endl;
150-
newline_ = true;
142+
debug_.newline = true;
151143
}
152144
else {
153145
std::cout << (isprint(p[i]) ? p[i] : '.');
@@ -156,7 +148,7 @@ long TCPSocket::write(const void* buf, long length) {
156148

157149
if (length > 512) {
158150
std::cout << "..." << std::endl;
159-
newline_ = true;
151+
debug_.newline = true;
160152
}
161153
}
162154

@@ -206,7 +198,7 @@ long TCPSocket::write(const void* buf, long length) {
206198
return sent;
207199
}
208200

209-
long TCPSocket::read(void* buf, long length) {
201+
long TCPSocket::read(void* buf, long length) const {
210202
if (length <= 0) {
211203
return length;
212204
}
@@ -270,19 +262,19 @@ long TCPSocket::read(void* buf, long length) {
270262
return received;
271263
}
272264

273-
if (debug_) {
265+
if (debug_.on) {
274266

275-
if (mode_ != 'r') {
276-
newline_ = true;
267+
if (debug_.mode != 'r') {
268+
debug_.newline = true;
277269
std::cout << std::endl
278270
<< std::endl;
279-
mode_ = 'r';
271+
debug_.mode = 'r';
280272
}
281273

282274
for (long i = 0; i < std::min(len, 512L); i++) {
283-
if (newline_) {
275+
if (debug_.newline) {
284276
std::cout << "<<< ";
285-
newline_ = false;
277+
debug_.newline = false;
286278
}
287279

288280
if (p[i] == '\r') {
@@ -291,7 +283,7 @@ long TCPSocket::read(void* buf, long length) {
291283
else if (p[i] == '\n') {
292284
std::cout << "\\n"
293285
<< std::endl;
294-
newline_ = true;
286+
debug_.newline = true;
295287
}
296288
else {
297289
std::cout << (isprint(p[i]) ? p[i] : '.');
@@ -300,11 +292,10 @@ long TCPSocket::read(void* buf, long length) {
300292

301293
if (len > 512) {
302294
std::cout << "..." << std::endl;
303-
newline_ = true;
295+
debug_.newline = true;
304296
}
305297
}
306298

307-
308299
received += len;
309300
length -= len;
310301
p += len;
@@ -810,9 +801,9 @@ bool TCPSocket::stillConnected() const {
810801
}
811802

812803
void TCPSocket::debug(bool on) {
813-
debug_ = on;
814-
newline_ = true;
815-
mode_ = 0;
804+
debug_.on = on;
805+
debug_.newline = true;
806+
debug_.mode = 0;
816807
}
817808

818809
void TCPSocket::print(std::ostream& s) const {

src/eckit/net/TCPSocket.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TCPSocket {
4747

4848
TCPSocket& operator=(net::TCPSocket&);
4949

50-
long write(const void* buf, long length);
50+
long write(const void* buf, long length) const;
5151

5252
/// Read from a TCP socket
5353
///
@@ -59,7 +59,7 @@ class TCPSocket {
5959
/// on flaky connections
6060
/// \arg **socketSelectTimeout** (*long*): timeout in seconds for the select
6161
/// (only if **useSelectOnTCPSocket** is enabled)
62-
long read(void* buf, long length);
62+
long read(void* buf, long length) const;
6363

6464
long rawRead(void*, long); // Non-blocking version
6565

@@ -121,9 +121,11 @@ class TCPSocket {
121121
int sendBufferSize_ = 0;
122122

123123
// Debug
124-
bool debug_;
125-
bool newline_;
126-
char mode_;
124+
struct {
125+
bool on {false};
126+
mutable bool newline {true};
127+
mutable char mode {0};
128+
} debug_;
127129

128130
protected: // methods
129131
int createSocket(int port, const SocketOptions& options);

0 commit comments

Comments
 (0)