|
24 | 24 | #include <memory> |
25 | 25 | #include <algorithm> |
26 | 26 |
|
27 | | -namespace o2 |
28 | | -{ |
29 | | -namespace DataDistribution |
| 27 | +namespace o2::DataDistribution |
30 | 28 | { |
31 | 29 |
|
32 | 30 | using namespace o2::header; |
@@ -126,22 +124,42 @@ void InterleavedHdrDataDeserializer::visit(SubTimeFrame& pStf) |
126 | 124 | } |
127 | 125 | } |
128 | 126 |
|
129 | | -std::unique_ptr<SubTimeFrame> InterleavedHdrDataDeserializer::deserialize(FairMQChannel& pChan) |
| 127 | +std::unique_ptr<SubTimeFrame> InterleavedHdrDataDeserializer::deserialize(FairMQChannel& pChan, bool pLogError) |
130 | 128 | { |
131 | | - const std::int64_t ret = pChan.Receive(mMessages, 500 /* ms */); |
132 | | - |
133 | | - // timeout ? |
134 | | - if (ret == -2) { |
135 | | - return nullptr; |
136 | | - } |
137 | | - |
138 | | - if (ret < 0) { |
139 | | - EDDLOG_RL(1000, "STF receive failed err={} errno={} error={}", ret, errno, std::string(strerror(errno))); |
140 | | - mMessages.clear(); |
141 | | - return nullptr; |
| 129 | + mMessages.clear(); |
| 130 | + const std::int64_t lRet = pChan.Receive(mMessages, 500 /* ms */); |
| 131 | + |
| 132 | + switch (lRet) { |
| 133 | + case static_cast<std::int64_t>(fair::mq::TransferCode::timeout): |
| 134 | + mMessages.clear(); |
| 135 | + return nullptr; |
| 136 | + break; |
| 137 | + case static_cast<std::int64_t>(fair::mq::TransferCode::interrupted): |
| 138 | + if (pLogError) { |
| 139 | + IDDLOG_RL(1000, "STF receive failed. what=fair::mq::TransferCode::interrupted"); |
| 140 | + } |
| 141 | + mMessages.clear(); |
| 142 | + return nullptr; |
| 143 | + break; |
| 144 | + case static_cast<std::int64_t>(fair::mq::TransferCode::error): |
| 145 | + EDDLOG_RL(1000, "STF receive failed. what=fair::mq::TransferCode::error err={} errno={} error={}", |
| 146 | + int(lRet), errno, std::string(strerror(errno))); |
| 147 | + mMessages.clear(); |
| 148 | + return nullptr; |
| 149 | + break; |
| 150 | + default: // data or zero |
| 151 | + if (lRet > 0) { |
| 152 | + return deserialize_impl(); |
| 153 | + } else { |
| 154 | + WDDLOG_RL(1000, "STF receive failed. what=zero_size"); |
| 155 | + mMessages.clear(); |
| 156 | + return nullptr; |
| 157 | + } |
| 158 | + break; |
142 | 159 | } |
143 | 160 |
|
144 | | - return deserialize_impl(); |
| 161 | + assert (false); |
| 162 | + return nullptr; |
145 | 163 | } |
146 | 164 |
|
147 | 165 | std::unique_ptr<SubTimeFrame> InterleavedHdrDataDeserializer::deserialize(FairMQParts& pMsgs) |
@@ -305,28 +323,44 @@ void CoalescedHdrDataDeserializer::visit(SubTimeFrame& pStf) |
305 | 323 | } |
306 | 324 | } |
307 | 325 |
|
308 | | -std::unique_ptr<SubTimeFrame> CoalescedHdrDataDeserializer::deserialize(FairMQChannel& pChan) |
| 326 | +std::unique_ptr<SubTimeFrame> CoalescedHdrDataDeserializer::deserialize(FairMQChannel& pChan, bool pLogError) |
309 | 327 | { |
310 | 328 | mHdrs.clear(); |
311 | 329 | mData.clear(); |
312 | 330 |
|
313 | | - const std::int64_t ret = pChan.Receive(mData, 500 /* ms */); |
| 331 | + const std::int64_t lRet = pChan.Receive(mData, 500 /* ms */); |
314 | 332 |
|
315 | | - // timeout ? |
316 | | - if (ret == -2) { |
317 | | - mData.clear(); |
318 | | - return nullptr; |
319 | | - } |
320 | | - |
321 | | - if (ret < 0) { |
322 | | - DDLOGF_GRL(1000, DataDistSeverity::error, "STF receive failed err={} errno={} error={}", ret, errno, |
323 | | - std::string(strerror(errno))); |
324 | | - |
325 | | - mData.clear(); |
326 | | - return nullptr; |
| 333 | + switch (lRet) { |
| 334 | + case static_cast<std::int64_t>(fair::mq::TransferCode::timeout): |
| 335 | + mData.clear(); |
| 336 | + return nullptr; |
| 337 | + break; |
| 338 | + case static_cast<std::int64_t>(fair::mq::TransferCode::interrupted): |
| 339 | + if (pLogError) { |
| 340 | + IDDLOG_RL(1000, "STF receive failed. what=fair::mq::TransferCode::interrupted"); |
| 341 | + } |
| 342 | + mData.clear(); |
| 343 | + return nullptr; |
| 344 | + break; |
| 345 | + case static_cast<std::int64_t>(fair::mq::TransferCode::error): |
| 346 | + EDDLOG_RL(1000, "STF receive failed. what=fair::mq::TransferCode::error err={} errno={} error={}", |
| 347 | + int(lRet), errno, std::string(strerror(errno))); |
| 348 | + mData.clear(); |
| 349 | + return nullptr; |
| 350 | + break; |
| 351 | + default: // data or zero |
| 352 | + if (lRet > 0) { |
| 353 | + return deserialize_impl(); |
| 354 | + } else { |
| 355 | + WDDLOG_RL(1000, "STF receive failed. what=zero_size"); |
| 356 | + mData.clear(); |
| 357 | + return nullptr; |
| 358 | + } |
| 359 | + break; |
327 | 360 | } |
328 | 361 |
|
329 | | - return deserialize_impl(); |
| 362 | + assert (false); |
| 363 | + return nullptr; |
330 | 364 | } |
331 | 365 |
|
332 | 366 | std::unique_ptr<SubTimeFrame> CoalescedHdrDataDeserializer::deserialize(std::vector<FairMQMessagePtr>& pMsgs) |
@@ -413,5 +447,4 @@ std::unique_ptr<SubTimeFrame> CoalescedHdrDataDeserializer::deserialize_impl() |
413 | 447 | return lStf; |
414 | 448 | } |
415 | 449 |
|
416 | | -} |
417 | 450 | } /* o2::DataDistribution */ |
0 commit comments