Commit a25a79ba authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Sort streams by ID.

* This ensures a consistent traversal on all I/O tasks.
parent f95409b5
......@@ -475,6 +475,14 @@ struct streamMap
int numEntries;
};
static int
smCmpStreamID(const void *a_, const void *b_)
{
const struct streamMapping *a = a_, *b = b_;
int streamIDa = a->streamID, streamIDb = b->streamID;
return (streamIDa > streamIDb) - (streamIDa < streamIDb);
}
static inline int
inventorizeStream(struct streamMapping *streamMap, int numStreamIDs,
int *sizeStreamMap_, int streamID, int headerIdx)
......@@ -581,6 +589,9 @@ buildStreamMap(union winHeaderEntry *winDict)
free(streamIDs);
}
/* sort written streams by streamID */
streamMap = xrealloc(streamMap, sizeof (streamMap[0]) * numStreamIDs);
qsort(streamMap, numStreamIDs, sizeof (streamMap[0]), smCmpStreamID);
return (struct streamMap){ .entries = streamMap, .numEntries = numStreamIDs };
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment