Commit e4283ddf authored by David Boucher's avatar David Boucher
Browse files

fix(broker/stats): access simplified

parent 81f5da8f
/*
* Copyright 2011 - 2021 Centreon (https://www.centreon.com/)
* Copyright 2011 - 2022 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -35,7 +35,7 @@ parser::parser() {}
parser::~parser() noexcept {}
/**
* Parse a XML buffer.
* Parse a JSON buffer.
*
* @param[out] entries Parsed entries.
* @param[in] content XML content.
......
......@@ -76,7 +76,6 @@ void worker::_close() {
close(_fd);
_fd = -1;
}
return;
}
/**
......@@ -106,7 +105,6 @@ void worker::_run() {
while (!_exit) {
// Check file opening.
if (_buffer.empty()) {
_close();
usleep(100000);
if (!_open())
continue;
......@@ -119,7 +117,7 @@ void worker::_run() {
fds.revents = 0;
// Multiplexing.
int flagged(poll(&fds, 1, 1000));
int flagged = poll(&fds, 1, 1000);
// Error.
if (flagged < 0) {
......@@ -142,11 +140,12 @@ void worker::_run() {
}
// Write data.
ssize_t wb(write(_fd, _buffer.c_str(), _buffer.size()));
if (wb > 0)
_buffer.erase(0, wb);
else
_buffer.clear();
ssize_t delta = 0;
while (delta < _buffer.size()) {
delta += write(_fd, _buffer.c_str() + delta, _buffer.size() - delta);
}
_close();
_buffer.clear();
}
}
}
......
Supports Markdown
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