Ensure key and page numbers are all 32 bits, robustify/fix packet handling internals

This commit is contained in:
Thulinma 2021-01-08 14:54:33 +01:00
parent 2a5a808107
commit 0a3c399a98
6 changed files with 69 additions and 60 deletions

View file

@ -201,7 +201,7 @@ static inline void show_stackframe(){}
#define SEM_STATISTICS "/MstStat"
#define SEM_USERS "/MstUser%s" //%s stream name
#define SHM_TRACK_DATA "MstData%s@%zu_%zu" //%s stream name, %zu track ID, %PRIu32 page #
#define SHM_TRACK_DATA "MstData%s@%zu_%" PRIu32 //%s stream name, %zu track ID, %PRIu32 page #
// End new meta
#define INPUT_USER_INTERVAL 1000
@ -258,12 +258,9 @@ static inline void show_stackframe(){}
#define STAT_EX_SIZE 177
#define PLAY_EX_SIZE 2 + 6 * SIMUL_TRACKS
#define INVALID_TRACK_ID 0xFFFFFFFF
#define INVALID_KEY_NUM 0xFFFFFFFF
#define INVALID_PAGE_NUM 0xFFFF
#define INVALID_RECORD_INDEX 0xFFFFFFFFFFFFFFFF
#define MAX_SIZE_T 0xFFFFFFFF
#define INVALID_TRACK_ID 0xFFFFFFFFu
#define INVALID_KEY_NUM 0xFFFFFFFFu
#define INVALID_RECORD_INDEX 0xFFFFFFFFFFFFFFFFull
#define NEW_TRACK_ID 0x80000000
#define QUICK_NEGOTIATE 0xC0000000

View file

@ -2157,7 +2157,7 @@ namespace DTSC{
if (t.pages.getInt("avail", i) == 0){continue;}
char thisPageName[NAME_BUFFER_SIZE];
snprintf(thisPageName, NAME_BUFFER_SIZE, SHM_TRACK_DATA, streamName.c_str(), trackIdx,
t.pages.getInt("firstkey", i));
(uint32_t)t.pages.getInt("firstkey", i));
IPC::sharedPage p(thisPageName, 20971520);
p.master = true;
}
@ -2201,7 +2201,7 @@ namespace DTSC{
// Initialize the correct page, make it master so it gets cleaned up when leaving scope.
char thisPageName[NAME_BUFFER_SIZE];
snprintf(thisPageName, NAME_BUFFER_SIZE, SHM_TRACK_DATA, streamName.c_str(), trackIdx,
t.pages.getInt("firstkey", t.pages.getDeleted()));
(uint32_t)t.pages.getInt("firstkey", t.pages.getDeleted()));
IPC::sharedPage p(thisPageName, 20971520);
p.master = true;
@ -3151,8 +3151,8 @@ namespace DTSC{
return pages.getInt("firstkey", res);
}
/// Given a key, returns the page number that timestamp can be found on.
/// If the key is not available, returns the closest page number that is.
/// Given a key, returns the page number it can be found on.
/// If the key is not available, returns the closest page that is.
size_t Meta::getPageNumberForKey(uint32_t idx, uint64_t keyNum) const{
const Util::RelAccX &pages = tracks.at(idx).pages;
size_t res = pages.getStartPos();