Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012-2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 17 | #include <ctype.h> |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 18 | #include <endian.h> |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 19 | #include <fcntl.h> |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 20 | #include <stdio.h> |
| 21 | #include <string.h> |
| 22 | #include <time.h> |
| 23 | #include <unistd.h> |
| 24 | |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 25 | #include <private/android_logger.h> |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 26 | |
Mark Salyzyn | 2ad0bd0 | 2016-02-23 08:55:43 -0800 | [diff] [blame] | 27 | #include "LogBuffer.h" |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 28 | #include "LogBufferElement.h" |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 29 | #include "LogCommand.h" |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 30 | #include "LogReader.h" |
Mark Salyzyn | 2ad0bd0 | 2016-02-23 08:55:43 -0800 | [diff] [blame] | 31 | #include "LogUtils.h" |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 32 | |
Mark Salyzyn | 5a34d6e | 2017-03-10 08:44:14 -0800 | [diff] [blame] | 33 | const log_time LogBufferElement::FLUSH_ERROR((uint32_t)-1, (uint32_t)-1); |
Mark Salyzyn | ee49c6a | 2015-06-12 14:59:42 -0700 | [diff] [blame] | 34 | atomic_int_fast64_t LogBufferElement::sequence(1); |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 35 | |
Mark Salyzyn | 7e2f83c | 2014-03-05 07:41:49 -0800 | [diff] [blame] | 36 | LogBufferElement::LogBufferElement(log_id_t log_id, log_time realtime, |
Mark Salyzyn | b992d0d | 2014-03-20 16:09:38 -0700 | [diff] [blame] | 37 | uid_t uid, pid_t pid, pid_t tid, |
Chih-Hung Hsieh | 08d470b | 2018-08-13 14:22:56 -0700 | [diff] [blame] | 38 | const char* msg, uint16_t len) |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 39 | : mUid(uid), |
| 40 | mPid(pid), |
| 41 | mTid(tid), |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 42 | mRealTime(realtime), |
| 43 | mMsgLen(len), |
Christopher Ferris | 74e74f9 | 2017-08-02 17:54:27 -0700 | [diff] [blame] | 44 | mLogId(log_id), |
| 45 | mDropped(false) { |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 46 | mMsg = new char[len]; |
| 47 | memcpy(mMsg, msg, len); |
| 48 | } |
| 49 | |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 50 | LogBufferElement::LogBufferElement(const LogBufferElement& elem) |
Christopher Ferris | 74e74f9 | 2017-08-02 17:54:27 -0700 | [diff] [blame] | 51 | : mUid(elem.mUid), |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 52 | mPid(elem.mPid), |
| 53 | mTid(elem.mTid), |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 54 | mRealTime(elem.mRealTime), |
| 55 | mMsgLen(elem.mMsgLen), |
Christopher Ferris | 74e74f9 | 2017-08-02 17:54:27 -0700 | [diff] [blame] | 56 | mLogId(elem.mLogId), |
| 57 | mDropped(elem.mDropped) { |
Jintao Zhu | 245fb36 | 2018-12-19 22:20:12 +0800 | [diff] [blame] | 58 | if (mDropped) { |
| 59 | if (elem.isBinary() && elem.mMsg != nullptr) { |
| 60 | // for the following "len" value, refer to : setDropped(uint16_t value), getTag() |
| 61 | const int len = sizeof(android_event_header_t); |
| 62 | mMsg = new char[len]; |
| 63 | memcpy(mMsg, elem.mMsg, len); |
| 64 | } else { |
| 65 | mMsg = nullptr; |
| 66 | } |
| 67 | } else { |
| 68 | mMsg = new char[mMsgLen]; |
| 69 | memcpy(mMsg, elem.mMsg, mMsgLen); |
| 70 | } |
Mark Salyzyn | a2c0222 | 2016-12-13 10:31:29 -0800 | [diff] [blame] | 71 | } |
| 72 | |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 73 | LogBufferElement::~LogBufferElement() { |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 74 | delete[] mMsg; |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Christopher Ferris | 74e74f9 | 2017-08-02 17:54:27 -0700 | [diff] [blame] | 77 | uint32_t LogBufferElement::getTag() const { |
| 78 | return (isBinary() && |
| 79 | ((mDropped && mMsg != nullptr) || |
| 80 | (!mDropped && mMsgLen >= sizeof(android_event_header_t)))) |
| 81 | ? reinterpret_cast<const android_event_header_t*>(mMsg)->tag |
| 82 | : 0; |
| 83 | } |
| 84 | |
Chih-Hung Hsieh | 08d470b | 2018-08-13 14:22:56 -0700 | [diff] [blame] | 85 | uint16_t LogBufferElement::setDropped(uint16_t value) { |
Christopher Ferris | 74e74f9 | 2017-08-02 17:54:27 -0700 | [diff] [blame] | 86 | // The tag information is saved in mMsg data, if the tag is non-zero |
| 87 | // save only the information needed to get the tag. |
| 88 | if (getTag() != 0) { |
| 89 | if (mMsgLen > sizeof(android_event_header_t)) { |
| 90 | char* truncated_msg = new char[sizeof(android_event_header_t)]; |
| 91 | memcpy(truncated_msg, mMsg, sizeof(android_event_header_t)); |
| 92 | delete[] mMsg; |
| 93 | mMsg = truncated_msg; |
| 94 | } // mMsgLen == sizeof(android_event_header_t), already at minimum. |
| 95 | } else { |
| 96 | delete[] mMsg; |
| 97 | mMsg = nullptr; |
| 98 | } |
| 99 | mDropped = true; |
| 100 | return mDroppedCount = value; |
| 101 | } |
| 102 | |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 103 | // caller must own and free character string |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 104 | char* android::tidToName(pid_t tid) { |
Yi Kong | c8d09dd | 2018-07-13 17:39:22 -0700 | [diff] [blame] | 105 | char* retval = nullptr; |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 106 | char buffer[256]; |
| 107 | snprintf(buffer, sizeof(buffer), "/proc/%u/comm", tid); |
| 108 | int fd = open(buffer, O_RDONLY); |
| 109 | if (fd >= 0) { |
| 110 | ssize_t ret = read(fd, buffer, sizeof(buffer)); |
| 111 | if (ret >= (ssize_t)sizeof(buffer)) { |
| 112 | ret = sizeof(buffer) - 1; |
| 113 | } |
| 114 | while ((ret > 0) && isspace(buffer[ret - 1])) { |
| 115 | --ret; |
| 116 | } |
| 117 | if (ret > 0) { |
| 118 | buffer[ret] = '\0'; |
| 119 | retval = strdup(buffer); |
| 120 | } |
| 121 | close(fd); |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 124 | // if nothing for comm, check out cmdline |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 125 | char* name = android::pidToName(tid); |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 126 | if (!retval) { |
| 127 | retval = name; |
Yi Kong | c8d09dd | 2018-07-13 17:39:22 -0700 | [diff] [blame] | 128 | name = nullptr; |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | // check if comm is truncated, see if cmdline has full representation |
| 132 | if (name) { |
| 133 | // impossible for retval to be NULL if name not NULL |
| 134 | size_t retval_len = strlen(retval); |
| 135 | size_t name_len = strlen(name); |
| 136 | // KISS: ToDo: Only checks prefix truncated, not suffix, or both |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 137 | if ((retval_len < name_len) && |
| 138 | !fastcmp<strcmp>(retval, name + name_len - retval_len)) { |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 139 | free(retval); |
| 140 | retval = name; |
| 141 | } else { |
| 142 | free(name); |
| 143 | } |
| 144 | } |
| 145 | return retval; |
| 146 | } |
| 147 | |
| 148 | // assumption: mMsg == NULL |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 149 | size_t LogBufferElement::populateDroppedMessage(char*& buffer, LogBuffer* parent, |
| 150 | bool lastSame) { |
Mark Salyzyn | 047cc07 | 2015-06-04 13:35:30 -0700 | [diff] [blame] | 151 | static const char tag[] = "chatty"; |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 152 | |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 153 | if (!__android_log_is_loggable_len(ANDROID_LOG_INFO, tag, strlen(tag), |
Mark Salyzyn | 807e40e | 2016-09-22 09:56:51 -0700 | [diff] [blame] | 154 | ANDROID_LOG_VERBOSE)) { |
Mark Salyzyn | e59c469 | 2014-10-02 13:07:05 -0700 | [diff] [blame] | 155 | return 0; |
| 156 | } |
| 157 | |
Mark Salyzyn | b5b8796 | 2017-01-23 14:20:31 -0800 | [diff] [blame] | 158 | static const char format_uid[] = "uid=%u%s%s %s %u line%s"; |
Mark Salyzyn | 3c501b5 | 2017-04-18 14:09:45 -0700 | [diff] [blame] | 159 | parent->wrlock(); |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 160 | const char* name = parent->uidToName(mUid); |
Mark Salyzyn | ed777e9 | 2015-06-24 16:22:54 -0700 | [diff] [blame] | 161 | parent->unlock(); |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 162 | const char* commName = android::tidToName(mTid); |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 163 | if (!commName && (mTid != mPid)) { |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 164 | commName = android::tidToName(mPid); |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 165 | } |
| 166 | if (!commName) { |
Mark Salyzyn | 3c501b5 | 2017-04-18 14:09:45 -0700 | [diff] [blame] | 167 | parent->wrlock(); |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 168 | commName = parent->pidToName(mPid); |
Mark Salyzyn | ed777e9 | 2015-06-24 16:22:54 -0700 | [diff] [blame] | 169 | parent->unlock(); |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 170 | } |
Mark Salyzyn | ddda212 | 2015-10-02 09:22:52 -0700 | [diff] [blame] | 171 | if (name && name[0] && commName && (name[0] == commName[0])) { |
| 172 | size_t len = strlen(name + 1); |
| 173 | if (!strncmp(name + 1, commName + 1, len)) { |
| 174 | if (commName[len + 1] == '\0') { |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 175 | free(const_cast<char*>(commName)); |
Yi Kong | c8d09dd | 2018-07-13 17:39:22 -0700 | [diff] [blame] | 176 | commName = nullptr; |
Mark Salyzyn | ddda212 | 2015-10-02 09:22:52 -0700 | [diff] [blame] | 177 | } else { |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 178 | free(const_cast<char*>(name)); |
Yi Kong | c8d09dd | 2018-07-13 17:39:22 -0700 | [diff] [blame] | 179 | name = nullptr; |
Mark Salyzyn | ddda212 | 2015-10-02 09:22:52 -0700 | [diff] [blame] | 180 | } |
Mark Salyzyn | 047cc07 | 2015-06-04 13:35:30 -0700 | [diff] [blame] | 181 | } |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 182 | } |
| 183 | if (name) { |
Yi Kong | c8d09dd | 2018-07-13 17:39:22 -0700 | [diff] [blame] | 184 | char* buf = nullptr; |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 185 | asprintf(&buf, "(%s)", name); |
| 186 | if (buf) { |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 187 | free(const_cast<char*>(name)); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 188 | name = buf; |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | if (commName) { |
Yi Kong | c8d09dd | 2018-07-13 17:39:22 -0700 | [diff] [blame] | 192 | char* buf = nullptr; |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 193 | asprintf(&buf, " %s", commName); |
| 194 | if (buf) { |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 195 | free(const_cast<char*>(commName)); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 196 | commName = buf; |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | // identical to below to calculate the buffer size required |
Mark Salyzyn | b5b8796 | 2017-01-23 14:20:31 -0800 | [diff] [blame] | 200 | const char* type = lastSame ? "identical" : "expire"; |
Yi Kong | c8d09dd | 2018-07-13 17:39:22 -0700 | [diff] [blame] | 201 | size_t len = snprintf(nullptr, 0, format_uid, mUid, name ? name : "", |
Christopher Ferris | 74e74f9 | 2017-08-02 17:54:27 -0700 | [diff] [blame] | 202 | commName ? commName : "", type, getDropped(), |
| 203 | (getDropped() > 1) ? "s" : ""); |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 204 | |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 205 | size_t hdrLen; |
Mark Salyzyn | 60636fa | 2016-10-24 16:22:17 -0700 | [diff] [blame] | 206 | if (isBinary()) { |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 207 | hdrLen = sizeof(android_log_event_string_t); |
| 208 | } else { |
| 209 | hdrLen = 1 + sizeof(tag); |
| 210 | } |
| 211 | |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 212 | buffer = static_cast<char*>(calloc(1, hdrLen + len + 1)); |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 213 | if (!buffer) { |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 214 | free(const_cast<char*>(name)); |
| 215 | free(const_cast<char*>(commName)); |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | size_t retval = hdrLen + len; |
Mark Salyzyn | 60636fa | 2016-10-24 16:22:17 -0700 | [diff] [blame] | 220 | if (isBinary()) { |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 221 | android_log_event_string_t* event = |
| 222 | reinterpret_cast<android_log_event_string_t*>(buffer); |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 223 | |
Mark Salyzyn | 47684ca | 2016-07-15 10:19:16 -0700 | [diff] [blame] | 224 | event->header.tag = htole32(CHATTY_LOG_TAG); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 225 | event->type = EVENT_TYPE_STRING; |
| 226 | event->length = htole32(len); |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 227 | } else { |
| 228 | ++retval; |
| 229 | buffer[0] = ANDROID_LOG_INFO; |
| 230 | strcpy(buffer + 1, tag); |
| 231 | } |
| 232 | |
Mark Salyzyn | 21fb7e0 | 2015-04-20 07:26:27 -0700 | [diff] [blame] | 233 | snprintf(buffer + hdrLen, len + 1, format_uid, mUid, name ? name : "", |
Christopher Ferris | 74e74f9 | 2017-08-02 17:54:27 -0700 | [diff] [blame] | 234 | commName ? commName : "", type, getDropped(), |
| 235 | (getDropped() > 1) ? "s" : ""); |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 236 | free(const_cast<char*>(name)); |
| 237 | free(const_cast<char*>(commName)); |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 238 | |
| 239 | return retval; |
| 240 | } |
| 241 | |
Mark Salyzyn | 5a34d6e | 2017-03-10 08:44:14 -0800 | [diff] [blame] | 242 | log_time LogBufferElement::flushTo(SocketClient* reader, LogBuffer* parent, |
Mark Salyzyn | b5b8796 | 2017-01-23 14:20:31 -0800 | [diff] [blame] | 243 | bool privileged, bool lastSame) { |
Mark Salyzyn | 7b87365 | 2015-12-03 15:38:35 -0800 | [diff] [blame] | 244 | struct logger_entry_v4 entry; |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 245 | |
Mark Salyzyn | 7b87365 | 2015-12-03 15:38:35 -0800 | [diff] [blame] | 246 | memset(&entry, 0, sizeof(struct logger_entry_v4)); |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 247 | |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 248 | entry.hdr_size = privileged ? sizeof(struct logger_entry_v4) |
| 249 | : sizeof(struct logger_entry_v3); |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 250 | entry.lid = mLogId; |
| 251 | entry.pid = mPid; |
Mark Salyzyn | b992d0d | 2014-03-20 16:09:38 -0700 | [diff] [blame] | 252 | entry.tid = mTid; |
Mark Salyzyn | 7b87365 | 2015-12-03 15:38:35 -0800 | [diff] [blame] | 253 | entry.uid = mUid; |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 254 | entry.sec = mRealTime.tv_sec; |
| 255 | entry.nsec = mRealTime.tv_nsec; |
| 256 | |
| 257 | struct iovec iovec[2]; |
| 258 | iovec[0].iov_base = &entry; |
Mark Salyzyn | 7b87365 | 2015-12-03 15:38:35 -0800 | [diff] [blame] | 259 | iovec[0].iov_len = entry.hdr_size; |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 260 | |
Yi Kong | c8d09dd | 2018-07-13 17:39:22 -0700 | [diff] [blame] | 261 | char* buffer = nullptr; |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 262 | |
Christopher Ferris | 74e74f9 | 2017-08-02 17:54:27 -0700 | [diff] [blame] | 263 | if (mDropped) { |
Mark Salyzyn | b5b8796 | 2017-01-23 14:20:31 -0800 | [diff] [blame] | 264 | entry.len = populateDroppedMessage(buffer, parent, lastSame); |
Mark Salyzyn | 5a34d6e | 2017-03-10 08:44:14 -0800 | [diff] [blame] | 265 | if (!entry.len) return mRealTime; |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 266 | iovec[1].iov_base = buffer; |
| 267 | } else { |
| 268 | entry.len = mMsgLen; |
| 269 | iovec[1].iov_base = mMsg; |
| 270 | } |
| 271 | iovec[1].iov_len = entry.len; |
| 272 | |
Mark Salyzyn | 479c8c2 | 2017-03-22 14:58:53 -0700 | [diff] [blame] | 273 | log_time retval = reader->sendDatav(iovec, 1 + (entry.len != 0)) |
| 274 | ? FLUSH_ERROR |
| 275 | : mRealTime; |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 276 | |
Mark Salyzyn | 501c373 | 2017-03-10 14:31:54 -0800 | [diff] [blame] | 277 | if (buffer) free(buffer); |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 278 | |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 279 | return retval; |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 280 | } |