Skip to content

Commit 6161dca

Browse files
authored
Merge pull request #41 from sy-c/master
minor osx fix
2 parents ff8de21 + f83d149 commit 6161dca

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/InfoLoggerClient.cxx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
#include "InfoLoggerClient.h"
3434
#include "infoLoggerDefaults.h"
3535

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+
3645
//////////////////////////////////////////////////////
3746
// class ConfigInfoLoggerClient
3847
// stores configuration params for infologgerD clients
@@ -213,8 +222,8 @@ int InfoLoggerClient::send(const char* message, unsigned int messageSize)
213222
// so, clean it up if needed
214223
reconnectThreadCleanup();
215224

216-
int flags = MSG_NOSIGNAL;
217-
int bytesWritten = ::send(txSocket, message, messageSize, MSG_NOSIGNAL);
225+
226+
int bytesWritten = ::send(txSocket, message, messageSize, sendFlags);
218227
if (bytesWritten == (int)messageSize) {
219228
mutex.unlock();
220229
return 0;
@@ -243,9 +252,8 @@ void InfoLoggerClient::reconnect() {
243252
log.info("Reconnection successful");
244253
int nFlushed = 0;
245254
while(!messageBuffer.empty()) {
246-
int flags = MSG_NOSIGNAL;
247255
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);
249257
if (bytesWritten == (int)messageSize) {
250258
messageBuffer.pop();
251259
nFlushed++;

0 commit comments

Comments
 (0)