summaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2014-03-25 13:24:52 +0100
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2014-04-01 09:46:43 +0200
commit20136d1af7dbf1d619499cc27e1c75e05368f3b6 (patch)
tree3cbd64d2cc9c8a14e772687a43f2c25619a224a6 /src/daemon
parent29e4f99d6db73e01e050726f1451b2d5f0281b7e (diff)
downloadDLT-daemon-20136d1af7dbf1d619499cc27e1c75e05368f3b6.tar.gz
Cygwin port: cygwin patch, signal handling patch and cppcheck and install lib dll to correct location on Windows. Originally from Mikko Rapeli <mikko.rapeli@bmw.de>.
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/dlt-daemon.c23
-rw-r--r--src/daemon/dlt_daemon_client.c7
-rw-r--r--src/daemon/dlt_daemon_socket.c6
3 files changed, 28 insertions, 8 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 2fb9f2f..bb3b86e 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -77,10 +77,14 @@
#include <errno.h>
#include <pthread.h>
+#ifdef linux
#include <sys/timerfd.h>
+#endif
#include <sys/stat.h>
#include <sys/time.h>
+#ifdef linux
#include <linux/stat.h>
+#endif
#include "dlt_types.h"
#include "dlt-daemon.h"
@@ -500,8 +504,13 @@ int main(int argc, char* argv[])
daemon_local.read_fds = daemon_local.master;
if (select(daemon_local.fdmax+1, &(daemon_local.read_fds), NULL, NULL, NULL) == -1)
{
- dlt_log(LOG_CRIT, "select() failed!\n");
- return -1 ;
+ int error = errno;
+ /* retry if SIGINT was received, else error out */
+ if ( error != EINTR ) {
+ sprintf(str,"select() failed: %s\n", strerror(error) );
+ dlt_log(LOG_CRIT, str);
+ return -1;
+ }
} /* if */
/* run through the existing FIFO and sockets to check for events */
@@ -1027,8 +1036,8 @@ void dlt_daemon_signal_handler(int sig)
case SIGQUIT:
{
/* finalize the server */
- //dlt_log("terminate signal catched");
- dlt_log(LOG_NOTICE, "Exiting DLT daemon\n");
+ sprintf(str,"Exiting DLT daemon due to signal: %s\n", strsignal(sig) );
+ dlt_log(LOG_NOTICE, str);
/* Try to delete existing pipe, ignore result of unlink() */
unlink(DLT_USER_FIFO);
@@ -1042,7 +1051,7 @@ void dlt_daemon_signal_handler(int sig)
}
default:
{
- /* This case should never occur */
+ dlt_log(LOG_CRIT, "This case should never happen!");
break;
}
} /* switch */
@@ -2383,7 +2392,7 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem
int create_timer_fd(DltDaemonLocal *daemon_local, int period_sec, int starts_in, int* fd, const char* timer_name)
{
- int local_fd;
+ int local_fd = -1;
struct itimerspec l_timer_spec;
if(timer_name == NULL)
@@ -2399,6 +2408,7 @@ int create_timer_fd(DltDaemonLocal *daemon_local, int period_sec, int starts_in,
}
if( period_sec > 0 ) {
+#ifdef linux
local_fd = timerfd_create(CLOCK_MONOTONIC, 0);
if( local_fd < 0)
{
@@ -2417,6 +2427,7 @@ int create_timer_fd(DltDaemonLocal *daemon_local, int period_sec, int starts_in,
dlt_log(DLT_LOG_ERROR, str);
local_fd = -1;
}
+#endif
}
else {
// timer not activated via the service file
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c
index a209975..30af665 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -63,10 +63,14 @@
#include <errno.h>
#include <pthread.h>
+#ifdef linux
#include <sys/timerfd.h>
+#endif
#include <sys/stat.h>
#include <sys/time.h>
+#ifdef linux
#include <linux/stat.h>
+#endif
#include "dlt_types.h"
#include "dlt-daemon.h"
@@ -1188,8 +1192,9 @@ int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, DltDaemonLo
time_t t = time(NULL);
struct tm lt = {0};
localtime_r(&t, &lt);
-
+#if !defined(__CYGWIN__)
resp->timezone = (int32_t) lt.tm_gmtoff;
+#endif
resp->isdst = (uint8_t) lt.tm_isdst;
/* send message */
diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c
index 12f16a8..a4dbe9f 100644
--- a/src/daemon/dlt_daemon_socket.c
+++ b/src/daemon/dlt_daemon_socket.c
@@ -64,10 +64,14 @@
#include <sys/ioctl.h>
#include <net/if.h>
+#ifdef linux
#include <sys/timerfd.h>
+#endif
#include <sys/stat.h>
#include <sys/time.h>
+#ifdef linux
#include <linux/stat.h>
+#endif
#include "dlt_types.h"
#include "dlt-daemon.h"
@@ -166,7 +170,7 @@ int dlt_daemon_socket_send(int sock,void* data1,int size1,void* data2,int size2,
int dlt_daemon_socket_get_send_qeue_max_size(int sock)
{
int n = 0;
- unsigned int m = sizeof(n);
+ socklen_t m = sizeof(n);
getsockopt(sock,SOL_SOCKET,SO_SNDBUF,(void *)&n, &m);
return n;