diff options
| author | Sebastian Schmelzer | 2011-09-01 19:27:46 +0200 |
|---|---|---|
| committer | Sebastian Schmelzer | 2011-09-01 19:27:46 +0200 |
| commit | 8fac1e425eca9487dda5465b74de84a2df8edddd (patch) | |
| tree | ac150eddef80e6bf18604e3d695f40e14dd2ef9b /customdhcpcd/src | |
| parent | some comments to the LogReceiver methods (diff) | |
| download | fbgui-8fac1e425eca9487dda5465b74de84a2df8edddd.tar.gz fbgui-8fac1e425eca9487dda5465b74de84a2df8edddd.tar.xz fbgui-8fac1e425eca9487dda5465b74de84a2df8edddd.zip | |
fix message loss
Diffstat (limited to 'customdhcpcd/src')
| -rwxr-xr-x | customdhcpcd/src/customdhcpcd | bin | 175292 -> 195074 bytes | |||
| -rw-r--r-- | customdhcpcd/src/logwriter.c | 24 | ||||
| -rw-r--r-- | customdhcpcd/src/logwriter.h | 2 |
3 files changed, 19 insertions, 7 deletions
diff --git a/customdhcpcd/src/customdhcpcd b/customdhcpcd/src/customdhcpcd Binary files differindex 65aedd0..80fec08 100755 --- a/customdhcpcd/src/customdhcpcd +++ b/customdhcpcd/src/customdhcpcd diff --git a/customdhcpcd/src/logwriter.c b/customdhcpcd/src/logwriter.c index 378d805..6a04821 100644 --- a/customdhcpcd/src/logwriter.c +++ b/customdhcpcd/src/logwriter.c @@ -18,6 +18,8 @@ #include "logwriter.h" #include "status.h" +#include "../../common/fbgui.h" // for constants + /*sockets for the logger and the qt-reader */ int sockfd, ns; int retval = -1; @@ -80,9 +82,11 @@ void logToQt(char * status, char * substatus, char * msg) { void sendToQt(log_msg * msg) { int n = -1; int t; + int ret; const char *tpl = "%s;%d;%d;%s\n"; - char *outbuf; - char ack[8]; + char outbuf[DHCP_MESSAGE_SIZE]; + char ack[ACK_SIZE]; + /* size_t outbuf_size = sizeof(char) * 4 + // ";" *3 + newline sizeof(int) * 2 + // status, substatus sizeof(msg->device) + // devicename @@ -92,10 +96,18 @@ void sendToQt(log_msg * msg) { snprintf(outbuf, sizeof(char) * 3 + sizeof(int) * 2 + sizeof(msg->device) + sizeof(msg->msg), tpl, msg->device, msg->status, msg->substatus, msg->msg); + */ + memset(outbuf, '\0', DHCP_MESSAGE_SIZE); + ret = snprintf(outbuf, DHCP_MESSAGE_SIZE, tpl, msg->device, msg->status, msg->substatus, + msg->msg); + if (ret < 1) { + syslog(LOG_INFO, "[fbgui] ERROR filling message buffer"); + return; + } if (outbuf != NULL) { - n = send(sockfd, outbuf, outbuf_size, 0); + n = send(sockfd, outbuf, DHCP_MESSAGE_SIZE, 0); } - free(outbuf); + //free(outbuf); syslog(LOG_INFO, "[fbgui] INFO writing to socket: [%d:%d] %s (%s)", msg->status, msg->substatus, msg->msg, msg->device); // fflush(sockfd); @@ -104,8 +116,8 @@ void sendToQt(log_msg * msg) { msg->status, msg->substatus, msg->msg, msg->device); // fprintf(stdout, "ERROR writing to socket: %s", msg); } - memset(ack,0,sizeof(ack)); - if ((t = recv(sockfd, ack, sizeof(ack), 0)) > 0) { + memset(ack,0,ACK_SIZE); + if ((t = recv(sockfd, ack, ACK_SIZE, 0)) > 0) { syslog(LOG_ERR, "[fbgui] recv ack echo> %s", ack); printf("received: %s\n", ack); } else { diff --git a/customdhcpcd/src/logwriter.h b/customdhcpcd/src/logwriter.h index 11693e5..1e4184d 100644 --- a/customdhcpcd/src/logwriter.h +++ b/customdhcpcd/src/logwriter.h @@ -32,6 +32,6 @@ void logToQt(int status, int substatus, const char * msg); void logSendToQt(int type); void logLoggerToQt(int level, const char *fmt, va_list args); //void logToQt(char * status, char * substatus, char * msg); -void logGatewayToFile(const interface_t *iface, const dhcp_t *dhcp); +//void logGatewayToFile(const interface_t iface, const dhcp_t dhcp); #endif /* LOGWRITER_H_ */ |
