C
cerr
Hi There,
My daemon app keeps terminating and i'm trying to figure out why and
where. I have a good idea tho. I'm using a push - pop FIFO system for
log messages. I have a syslog message after the push and after the pop
function and see both appearingh all the time and hence i think that
both, push() and pop() works fine. However, the messages get popped
off in a thread from where i send the data off. I'm using following
code:
pthread_mutex_lock(&log_mtx);
Qstr=pop(&msglist, &locLen);
syslog(LOG_ERR, "DUBUG: popped succesfully!");
strncpy(res,Qstr,LOG_BUF_SIZE);
res[LOG_BUF_SIZE]='\0';
strcat(res,"\n");
pthread_mutex_unlock(&log_mtx);
if (log_sock>-1) {
sndlen=strlen(res);
reclen=send(log_sock, res, sndlen, 0);
if (reclen != sndlen) {
if (reclen==-1){
syslog(LOG_ERR, "nlog: send failed...,errno: %s!", strerror
( errno ));
}
syslog(LOG_ERR, "nlog: \"%s\" not sent, strlen(%d) - sent %d",res,
sndlen, reclen);
}
else {
syslog(LOG_ERR, "DEBUG: sent okay, receive ack");
The last message I see in syslog before my app crashes is "DUBUG:
popped succesfully!"
Now the declaration of those variables are as follows:
char res[LOG_BUF_SIZE+2]={0};
char *Qstr;
int locLen;
int sndlen;
while msglist is from type char** and QLen from type int and declared
globally.
LOG_BUF_SIZE is a define and set to 512.
Does anyone have a clue where my app is terminating and or should i be
looking somewhere else all together? The system worked fine before i
implemented this new FIFO system...
Thanks for hints and suggestions!
Ron
My daemon app keeps terminating and i'm trying to figure out why and
where. I have a good idea tho. I'm using a push - pop FIFO system for
log messages. I have a syslog message after the push and after the pop
function and see both appearingh all the time and hence i think that
both, push() and pop() works fine. However, the messages get popped
off in a thread from where i send the data off. I'm using following
code:
pthread_mutex_lock(&log_mtx);
Qstr=pop(&msglist, &locLen);
syslog(LOG_ERR, "DUBUG: popped succesfully!");
strncpy(res,Qstr,LOG_BUF_SIZE);
res[LOG_BUF_SIZE]='\0';
strcat(res,"\n");
pthread_mutex_unlock(&log_mtx);
if (log_sock>-1) {
sndlen=strlen(res);
reclen=send(log_sock, res, sndlen, 0);
if (reclen != sndlen) {
if (reclen==-1){
syslog(LOG_ERR, "nlog: send failed...,errno: %s!", strerror
( errno ));
}
syslog(LOG_ERR, "nlog: \"%s\" not sent, strlen(%d) - sent %d",res,
sndlen, reclen);
}
else {
syslog(LOG_ERR, "DEBUG: sent okay, receive ack");
The last message I see in syslog before my app crashes is "DUBUG:
popped succesfully!"
Now the declaration of those variables are as follows:
char res[LOG_BUF_SIZE+2]={0};
char *Qstr;
int locLen;
int sndlen;
while msglist is from type char** and QLen from type int and declared
globally.
LOG_BUF_SIZE is a define and set to 512.
Does anyone have a clue where my app is terminating and or should i be
looking somewhere else all together? The system worked fine before i
implemented this new FIFO system...
Thanks for hints and suggestions!
Ron