Skip to content

Commit cfed25c

Browse files
committed
fix daemon startup failure
1 parent b273fd0 commit cfed25c

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/infoLoggerD.cxx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,16 @@ class InfoLoggerD:public Daemon {
192192

193193
private:
194194

195-
int isInitialized;
195+
int isInitialized=0;
196196

197197
ConfigInfoLoggerD configInfoLoggerD; // object for configuration parameters
198-
int rxSocket; // socket for incoming messages
198+
int rxSocket=-1; // socket for incoming messages
199199

200-
unsigned long long numberOfMessagesReceived;
200+
unsigned long long numberOfMessagesReceived=0;
201201
std::list<t_clientConnection> clients;
202202

203203
TR_client_configuration cfgCx; // config for transport
204-
TR_client_handle hCx; // handle to server transport
204+
TR_client_handle hCx=nullptr; // handle to server transport
205205

206206
FILE *logOutput=nullptr; // handle to local log file where to copy incoming messages, if configured to do so
207207
};
@@ -298,7 +298,7 @@ InfoLoggerD::InfoLoggerD(int argc,char * argv[]):Daemon(argc,argv) {
298298
}
299299

300300
hCx = TR_client_start(&cfgCx);
301-
if (hCx==NULL) {
301+
if (hCx==nullptr) {
302302
throw __LINE__;
303303
}
304304
} else {
@@ -323,15 +323,17 @@ InfoLoggerD::InfoLoggerD(int argc,char * argv[]):Daemon(argc,argv) {
323323

324324

325325
InfoLoggerD::~InfoLoggerD() {
326-
log.info("Received %llu messages",numberOfMessagesReceived);
326+
if (isInitialized) {
327+
log.info("Received %llu messages",numberOfMessagesReceived);
328+
}
327329

328330
if (rxSocket>=0) {
329331
close(rxSocket);
330332
}
331333
for (auto c : clients) {
332334
close(c.socket);
333335
}
334-
if (configInfoLoggerD.outputToServer) {
336+
if (hCx!=nullptr) {
335337
TR_client_stop(hCx);
336338
}
337339
}

0 commit comments

Comments
 (0)