MCPcopy Create free account
hub / github.com/apache/trafficserver / RecMessageUnmarshalNext

Function RecMessageUnmarshalNext

src/records/RecMessage.cc:176–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174//-------------------------------------------------------------------------
175
176int
177RecMessageUnmarshalNext(RecMessage *msg, RecMessageItr *itr, RecRecord **record)
178{
179 RecMessageEleHdr *eh;
180 RecRecord *r;
181
182 if (itr == nullptr) {
183 if (msg->entries == 0) {
184 return REC_ERR_FAIL;
185 } else {
186 eh = reinterpret_cast<RecMessageEleHdr *>(reinterpret_cast<char *>(msg) + msg->o_start);
187 }
188 } else {
189 if (itr->next >= msg->entries) {
190 return REC_ERR_FAIL;
191 }
192 itr->ele_hdr = reinterpret_cast<RecMessageEleHdr *>(reinterpret_cast<char *>(msg) + itr->ele_hdr->o_next);
193 itr->next += 1;
194 eh = itr->ele_hdr;
195 }
196
197 ink_assert(eh->magic == REC_MESSAGE_ELE_MAGIC);
198
199 // If the file is corrupt, ignore the rest of the file.
200 if (eh->magic != REC_MESSAGE_ELE_MAGIC) {
201 Warning("Persistent statistics file records.stat is corrupted. Ignoring the rest of the file\n");
202 return REC_ERR_FAIL;
203 }
204
205 r = reinterpret_cast<RecRecord *>(reinterpret_cast<char *>(eh) + sizeof(RecMessageEleHdr));
206
207 if (r->name) {
208 r->name = reinterpret_cast<char *>(r) + (intptr_t)(r->name);
209 }
210 if (r->data_type == RECD_STRING) {
211 if (r->data.rec_string) {
212 r->data.rec_string = reinterpret_cast<char *>(r) + (intptr_t)(r->data.rec_string);
213 }
214 if (r->data_default.rec_string) {
215 r->data_default.rec_string = reinterpret_cast<char *>(r) + (intptr_t)(r->data_default.rec_string);
216 }
217 }
218 if (REC_TYPE_IS_CONFIG(r->rec_type) && (r->config_meta.check_expr)) {
219 r->config_meta.check_expr = reinterpret_cast<char *>(r) + (intptr_t)(r->config_meta.check_expr);
220 }
221
222 *record = r;
223
224 return REC_ERR_OKAY;
225}
226
227//-------------------------------------------------------------------------
228// RecMessageRegisterRecvCb

Callers 2

RecMessageUnmarshalFirstFunction · 0.85
RecReadStatsFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected