logd: strip out empty trailing iovec

If the last buffer has zero length, strip it out of the iovec
issued to SocketClient::sendDatav().

Test: gTest liblog-unit-tests, logd-unit-tests, logcat-unit-tests
Bug: 36497967
Change-Id: I8fc585bbec63402d0e818ff4c620fdd7edcc38dc
This commit is contained in:
Mark Salyzyn 2017-03-22 14:58:53 -07:00
parent e6b7328b57
commit dd609d810b

View file

@ -235,7 +235,9 @@ log_time LogBufferElement::flushTo(SocketClient* reader, LogBuffer* parent,
}
iovec[1].iov_len = entry.len;
log_time retval = reader->sendDatav(iovec, 2) ? FLUSH_ERROR : mRealTime;
log_time retval = reader->sendDatav(iovec, 1 + (entry.len != 0))
? FLUSH_ERROR
: mRealTime;
if (buffer) free(buffer);