Re: [Mvpmc-devel] libcmyth and xbmc
Status: Alpha
Brought to you by:
gettler
From: Tom M. <tme...@gm...> - 2010-12-13 17:06:12
|
Charles Barnwell wrote: > For 0.23.1 the developers decided to use 23056. Apparently this > is because 57 was already taken, so 23056 is an interim version. I don't follow. Isn't the protocol version number supposed to be a monotonically increasing integer? If 57 was already in use, then why wouldn't they use 58? What is it they said needed to be resolved before they resume using 56? > ...doing something along the lines "if version == 23056 version = > 56"... Doesn't that run the risk that someday the back-end will report 56 and mean a different set of behaviors than 23056? > ...but I'd like to be more general still. I'm thinking along the > lines of if version > 1000, then only use the last two digits, but my > rusty C coding is not up to it. 23056 % 100 will achieve the result you want, but it isn't clear to me why he developers would make a regular pattern of prefixing the protocol version with the server version. With only one case of this as a precedent, you probably need something that can handle arbitrary mappings. Eric Lund wrote: > One or notway to mitigate that risk would be to create a new field in > the connection structure, something like 'conn_local_version' and > then change all the version checks to use that. Then 'conn_version' > would remain unchanged from what myth sent and 'conn_local_version' > would be the normalized version. This sounds like a good approach. The down side is that you'll end up with local versions numbers that mostly look just like the external version numbers, so a future developer will see a comparison to 56 in the code and assume that means protocol version 56. That could lead to some confusion. Another approach would be to use bitmasks for each behavior that needs to be conditionally enabled. Then at the start you'd have a switch statement to map the protocol versions to a bit pattern. This approach has some scaling limits, such as 32 independent behaviors, if you're using 32-bit integers. And makes less sense if many of your version checks are relational tests (if version > 39 ...). -Tom |