Commit 561c39ac authored by Micha Mueller's avatar Micha Mueller
Browse files

Pusher: caliper plugin: improve log messages

parent 78ee6cd6
......@@ -29,6 +29,7 @@
#include <errno.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "timestamp.h"
......@@ -68,7 +69,7 @@ void CaliperSensorGroup::start() {
_socket = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_NONBLOCK, 0);
if(_socket == -1) {
LOG(error) << _groupName << ": Failed to open socket:" << strerror(errno);
LOG(error) << _groupName << ": Failed to open socket: " << strerror(errno);
return;
}
......@@ -79,14 +80,14 @@ void CaliperSensorGroup::start() {
snprintf(&addr.sun_path[1], 91, "DCDBPusherCaliSocket");
if(bind(_socket, (struct sockaddr*) &addr, sizeof(addr))) {
LOG(error) << _groupName << ": Failed to bind socket:" << strerror(errno);
LOG(error) << _groupName << ": Failed to bind socket: " << strerror(errno);
close(_socket);
_socket = -1;
return;
}
if(listen(_socket, 1)) {
LOG(error) << _groupName << ": Can not listen on socket:" << strerror(errno);
LOG(error) << _groupName << ": Can not listen on socket: " << strerror(errno);
close(_socket);
_socket = -1;
return;
......@@ -121,7 +122,7 @@ void CaliperSensorGroup::read() {
_connection = accept(_socket, NULL, NULL);
if (_connection == -1) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
LOG(error) << _groupName << ": Accept failed:" << strerror(errno);
LOG(error) << _groupName << ": Accept failed: " << strerror(errno);
}
return;
}
......@@ -130,10 +131,12 @@ void CaliperSensorGroup::read() {
const size_t bufSize = 2048;
char buf[bufSize];
const ssize_t nrec = recv(_connection, (void *) buf, bufSize, MSG_DONTWAIT);
LOG(debug) << _groupName << ": Receiving message...";
if (nrec == 0) {
close(_connection);
_connection = -1;
LOG(debug) << _groupName << ": Connection closed";
return;
} else if (nrec == -1) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment