return -ENOTCONN;
}
- while (true) {
- auto it = std::find(desc.input.begin(), desc.input.end(), '\n');
-
- if (it == desc.input.end()) {
- if (desc.input.size() > MAX_MESSAGE_LENGTH) {
- closeConnection(fd);
- ALOGE("Message too long, length: " << desc.input.size() << " file descriptor: " << fd);
- return -ENOTCONN;
- }
- break;
- }
+ auto it = std::find(desc.input.begin(), desc.input.end(), '\n');
+ if (it == desc.input.end()) {
+ if (desc.input.size() > MAX_MESSAGE_LENGTH) {
+ closeConnection(fd);
+ ALOGE("Message too long, length: " << desc.input.size() << " file descriptor: " << fd);
+ return -ENOTCONN;
+ }
+ } else {
std::size_t len = static_cast<std::size_t>(std::distance(desc.input.begin(), it)) + 1;
if (len < MIN_MESSAGE_LENGTH || len > MAX_MESSAGE_LENGTH) {
closeConnection(fd);
parse(strMessage, message);
int status = onReceive(fd, std::move(message));
+ if (status == -ENOTCONN) {
+ return status;
+ }
if (status < 0) {
closeConnection(fd);
ALOGE("Problem while processing received message for file descriptor: " << fd);