Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ugc
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2019-02-22 17:30:50 +0300
committerAleksey Belousov <beloal@users.noreply.github.com>2019-03-01 18:28:21 +0300
commitea9968fc61f161ffcb477cc33f1cc794e42b015b (patch)
tree149de49a2b9dd38d8d85b86b6f7a7bd6c8c09b42 /ugc
parentb7c2c2d835633be438af7dde78496162a18a133b (diff)
[ugc] Stability improvment + statistics
Diffstat (limited to 'ugc')
-rw-r--r--ugc/storage.cpp55
1 files changed, 47 insertions, 8 deletions
diff --git a/ugc/storage.cpp b/ugc/storage.cpp
index 2ec5cd4815..0113f5fb4f 100644
--- a/ugc/storage.cpp
+++ b/ugc/storage.cpp
@@ -64,8 +64,48 @@ void DeserializeIndexes(string const & jsonData, ugc::UpdateIndexes & res)
if (jsonData.empty())
return;
- ugc::DeserializerJsonV0 des(jsonData);
- des(res);
+ try
+ {
+ ugc::DeserializerJsonV0 des(jsonData);
+ des(res);
+ }
+ catch (base::Json::Exception const & e)
+ {
+ LOG(LERROR, ("Exception while indexes deserialization. Reason:", e.what()));
+ map<string, string> const stat = {
+ {"error", "Cannot deserialize indexes. Content: " + jsonData}};
+ alohalytics::Stats::Instance().LogEvent("UGC_File_error", stat);
+ res.clear();
+ }
+}
+
+void DeserializeUGCUpdate(vector<uint8_t> const & buf, ugc::UGCUpdate & dst)
+{
+ MemReaderWithExceptions r(buf.data(), buf.size());
+ NonOwningReaderSource source(r);
+
+ try
+ {
+ ugc::Deserialize(source, dst);
+ return;
+ }
+ catch (ugc::BadBlob const & e)
+ {
+ LOG(LERROR, ("BadBlob exception while UGCUpdate deserialization. Reason:", e.what()));
+ map<string, string> const stat = {
+ {"error", "Cannot deserialize UGCUpdate. Bad blob exception. Content: " +
+ std::string(buf.cbegin(), buf.cend())}};
+ alohalytics::Stats::Instance().LogEvent("UGC_File_error", stat);
+ }
+ catch (Reader::Exception const & e)
+ {
+ LOG(LERROR, ("Exception while UGCUpdate deserialization. Reason:", e.what()));
+ map<string, string> const stat = {{"error", "Cannot deserialize UGCUpdate. Content: " +
+ std::string(buf.cbegin(), buf.cend())}};
+ alohalytics::Stats::Instance().LogEvent("UGC_File_error", stat);
+ }
+
+ dst = {};
}
string SerializeIndexes(ugc::UpdateIndexes const & indexes)
@@ -178,10 +218,8 @@ UGCUpdate Storage::GetUGCUpdate(FeatureID const & id) const
return {};
}
- MemReader r(buf.data(), buf.size());
- NonOwningReaderSource source(r);
UGCUpdate update;
- Deserialize(source, update);
+ DeserializeUGCUpdate(buf, update);
return update;
}
@@ -410,10 +448,11 @@ string Storage::GetUGCToSend() const
return string();
}
- MemReader r(buf.data(), buf.size());
- NonOwningReaderSource source(r);
UGCUpdate update;
- Deserialize(source, update);
+ DeserializeUGCUpdate(buf, update);
+
+ if (update.IsEmpty())
+ continue;
string data;
{