Skip to content

Commit

Permalink
Prevent individually malformed EPG data request results from aborting…
Browse files Browse the repository at this point in the history
… all remaining requests
  • Loading branch information
djp952 committed May 9, 2019
1 parent 0c5bb61 commit 0c56b58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pvr.hdhomerundvr/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
v2.0.2 (2019.xx.xx)
v2.0.2 (2019.05.08)
- Update SQLite database engine to version 3.28.0
- Prevent multiple Kodi threads from simultaneously requesting EPG data
- Prevent individually malformed EPG data request results from aborting all remaining requests
- Fix bug that allowed extraneous EPG entries to be transferred to Kodi
- Fix bug that prevented successfully setting channel visibility flags
- Fix bug in database layer that could cause unhandled exceptions processing NULL column values
Expand Down
15 changes: 13 additions & 2 deletions src/dbextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

#include <algorithm>
#include <list>
#include <rapidjson/document.h>
#include <sqlite3ext.h>
#include <string>
#include <strings.h>
#include <uuid/uuid.h>
#include <xbmc_pvr_types.h>
#include <vector>
Expand Down Expand Up @@ -559,8 +561,17 @@ int epg_filter(sqlite3_vtab_cursor* cursor, int /*indexnum*/, char const* /*inde
if(responsecode == 0) throw string_exception("no response from host");
else if((responsecode < 200) || (responsecode > 299)) throw http_exception(responsecode);

// HTTP 200: OK was received, add the transferred data into the cursor object as a new row
epgcursor->rows.emplace_back(std::move(transfer.second));
// Ignore transfers that returned no data or begin with the string "null"
if((transfer.second.size() > 0) && (strcasecmp(reinterpret_cast<const char*>(transfer.second.c_str()), "null") != 0)) {

// Validate the JSON document returned from the query has no parse error(s)
rapidjson::Document json;
json.Parse(reinterpret_cast<const char*>(transfer.second.data()), transfer.second.size());

// Ignore any transfers that returned invalid JSON data (for now, ultimately I would like
// to add a retry operation here for the individual bad transfers)
if(!json.HasParseError()) epgcursor->rows.emplace_back(std::move(transfer.second));
}
}

// Clean up and destroy the generated cURL easy interface handles
Expand Down

0 comments on commit 0c56b58

Please sign in to comment.