|
33 | 33 | #include "InfoLoggerClient.h" |
34 | 34 | #include "infoLoggerDefaults.h" |
35 | 35 |
|
| 36 | +#ifndef MSG_NOSIGNAL |
| 37 | + #ifdef SO_NOSIGPIPE |
| 38 | + #define MSG_NOSIGNAL SO_NOSIGPIPE |
| 39 | + #else |
| 40 | + #define MSG_NOSIGNAL 0 |
| 41 | + #endif |
| 42 | +#endif |
| 43 | +const int sendFlags = MSG_NOSIGNAL; |
| 44 | + |
36 | 45 | ////////////////////////////////////////////////////// |
37 | 46 | // class ConfigInfoLoggerClient |
38 | 47 | // stores configuration params for infologgerD clients |
@@ -213,8 +222,8 @@ int InfoLoggerClient::send(const char* message, unsigned int messageSize) |
213 | 222 | // so, clean it up if needed |
214 | 223 | reconnectThreadCleanup(); |
215 | 224 |
|
216 | | - int flags = MSG_NOSIGNAL; |
217 | | - int bytesWritten = ::send(txSocket, message, messageSize, MSG_NOSIGNAL); |
| 225 | + |
| 226 | + int bytesWritten = ::send(txSocket, message, messageSize, sendFlags); |
218 | 227 | if (bytesWritten == (int)messageSize) { |
219 | 228 | mutex.unlock(); |
220 | 229 | return 0; |
@@ -243,9 +252,8 @@ void InfoLoggerClient::reconnect() { |
243 | 252 | log.info("Reconnection successful"); |
244 | 253 | int nFlushed = 0; |
245 | 254 | while(!messageBuffer.empty()) { |
246 | | - int flags = MSG_NOSIGNAL; |
247 | 255 | size_t messageSize = messageBuffer.front().size(); |
248 | | - int bytesWritten = ::send(txSocket, messageBuffer.front().c_str(), messageSize, MSG_NOSIGNAL); |
| 256 | + int bytesWritten = ::send(txSocket, messageBuffer.front().c_str(), messageSize, sendFlags); |
249 | 257 | if (bytesWritten == (int)messageSize) { |
250 | 258 | messageBuffer.pop(); |
251 | 259 | nFlushed++; |
|
0 commit comments