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