void GetCollector::insert(uint64_t id, std::string file, HttpResponse res) { if (res.code() == 200) { m_data.insert(std::make_pair(id, res.data())); } else { delete res.data(); if (res.code() != 404) { // 404s are expected, since we are querying nodes from a theoretical // completely full tree. if (res.code() / 100 == 5) m_shouldSlowDown = true; std::lock_guard<std::mutex> lock(m_mutex); m_errs.insert(std::make_pair(id, file)); } } // Increment at the end, so if this is the last response, we will // notify 'done' after all possible errors have been captured. inc(); }
void PutCollector::insert( uint64_t id, HttpResponse res, const std::vector<uint8_t>* data) { if (res.code() == 200) { if (data) delete data; } else { if (res.code() / 100 == 5) m_shouldSlowDown = true; std::lock_guard<std::mutex> lock(m_mutex); m_errs.insert(std::make_pair(id, data)); } // Increment at the end, so if this is the last response, we will // notify 'done' after all possible errors have been captured. inc(); }