Re: PeerInfo and PeerId

Hi Petr,

The reason why I left only eventAsString() was that adding a new event to the TrackerRequest would cause only this class to be updated, not anything else (I mean TrackerRequestWriter). But to be consistent, I’ll move this function to the TrackerRequestWriter, so TrackerRequest will be just an “advance struct”.

Yes, it is just an advanced struct with reference counting!

We could have the compiler help us in case a new Event is ever added to TrackerReqeust::Event. If TrackerRequestWriter::eventToString() uses a simple switch like that:

switch (event)
{
case Empty: return “empty”;
case Started: return “started”;
case Completed: return “completed”;
case Stopped: return “stopped”;
}

the compiler will produce a warning that no case exists for the new enum value, which would be a hint for us to fix that! If we forget to change the Writer after a new Event has been added, then the line:

return EventsAsStrings[event];

could be troublesome. What do you think?

Btw. I think the reason for this strange crash of tester is that global PeerIdQueryItemKeyName is not yet initialized by the time const TrackerRequest TrackerRequestSessionTest::ValidTrackerRequest (TrackerRequestSessionTest.cpp:190) is constructed. I remember reading that the order in which static/global variables is undefined so probably we have other situations like this that “just work” with the specific version of gcc we are using but will probably not work with different compilers. We have to think of a solution or a workaround to the problem.

Regards,

Peter

Would you like to post a relpy?


This post is a reply to:
Re: PeerInfo and PeerId
Hi Peter, Hm, haven’t thought of that - it makes sense with multi tracker torrents but I think it would be rare that all are queried at the same time (maybe (more...)

Follow-ups:
Re: PeerInfo and PeerId
Hi Peter, We could have the compiler help us in case a new Event is ever added to TrackerReqeust::Event. If TrackerRequestWriter::eventToString() uses a simple switch like that: [snip] the compiler will produce a (more...)