From 12589345ce587368c5eb88eb1fcf58ac26f4527a Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 16 Feb 2021 14:41:55 +0100 Subject: [PATCH] final fixes --- include/villas/dumper.hpp | 6 +++++- lib/dumper.cpp | 40 +++++++++++++++++++++++++-------------- lib/hooks/dft.cpp | 2 ++ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/include/villas/dumper.hpp b/include/villas/dumper.hpp index 6e0482454..4d8bfd225 100644 --- a/include/villas/dumper.hpp +++ b/include/villas/dumper.hpp @@ -21,6 +21,8 @@ * along with this program. If not, see . *********************************************************************************/ +#pragma once + #include namespace villas { @@ -37,8 +39,10 @@ protected: public: Dumper(const std::string &socketNameIn); ~Dumper(); + int openSocket(); - void closeSocket(); + int closeSocket(); + void writeData(uint len, double *yData, double *xData = nullptr); }; diff --git a/lib/dumper.cpp b/lib/dumper.cpp index c70ec4035..4bbabc191 100644 --- a/lib/dumper.cpp +++ b/lib/dumper.cpp @@ -20,13 +20,16 @@ * along with this program. If not, see . *********************************************************************************/ -#include #include #include #include -#include #include +#include + +#include +#include + using namespace villas; using namespace villas::node; @@ -54,28 +57,37 @@ int Dumper::openSocket() socketaddrUn.sun_family = AF_UNIX; strcpy(socketaddrUn.sun_path, socketName.c_str()); - connect(socketFd, (struct sockaddr *) &socketaddrUn, sizeof(socketaddrUn)); + int ret = connect(socketFd, (struct sockaddr *) &socketaddrUn, sizeof(socketaddrUn)); + if (!ret) + return ret; - return 1; + return 0; } -void Dumper::closeSocket() +int Dumper::closeSocket() { - close(socketFd); + int ret = close(socketFd); + if (!ret) + return ret; + + return 0; } void Dumper::writeData(unsigned len, double *yData, double *xData) { - ssize_t bytesWritten; - for (unsigned i = 0; i