Re: BitTorrent branch refactoring

Hi all,

Attached is the log from valgrind after running the tester. Simply running the tester from the console results in segmentation fault. It’s strange this only happens when using PacketStub together with PacketDriver. From I can see from the log, when the shared data is copied, only the a partial copy is created - acutally only the part Generics::Packet::Data.

Also, it seems that not the right specialization of PacketDriver::readHeader() is called. The log says PacketDriver.h:201 but if must actually be PacketDriver.cpp:46.

I’ll look further into that but nevertheless any suggestions are welcome.

Regards,

Peter

Peter Dimov wrote:Hello everybody,

There are quite some changes in my BitTorrent branch (http://bzr.calitko.org/developers/peter/calitko-BitTorrent). Attached is the latest patch.

Finally isValid() is completely removed from Protocols::Generics::Packet as well as the raw data ctors of the same class and all its derived classes.

New and in my opinion quite interesting are the classes PacketStub and PacketDriver. Please take a look at them and at their documentation. I’d be interested in comments about the documentation itself and the work the classes are doing. I liked a lot Atul’s idea to make a template class that can be used for unit testing all classes Packet’s inheritance hierarchy and you can already see that in action. PacketDriver gives access to the protected members of Packet derived classes and makes test that would have been impossible possible and this with only little or no additional code. Actually for the BitTorrent packets I had to make a template specialization to make instantiation of PacketDrive possible.

I have a strange problem with running the last test in Protocols/BitTorrent/Packets/PacketTest.cpp. If line 117 is uncommented the tester app will crash due to modified heap data. I couldn’t trace the reason of that; maybe someone of you can take a look? Maybe it’s a good idea to use valgrind to spot the problem.

I also created a much nicer, in my opinion, stub for Generics::PacketFactory. Someone might want to take a look ;-).

Regards,

Peter

Attached Files:

Would you like to post a relpy?


This post is a reply to:
BitTorrent branch refactoring
Hello everybody, There are quite some changes in my BitTorrent branch (http://bzr.calitko.org/developers/peter/calitko-BitTorrent). Attached is the latest patch. Finally isValid() is completely removed from Protocols::Generics::Packet as well as the raw data ctors (more...)

Follow-ups:
Re: Re: BitTorrent branch refactoring
Just figured out where exactly the problem is: template Q_OUTOFLINE_TEMPLATE void QSharedDataPointer::detach_helper() { T *x = new T(*d); x->ref.ref(); x = qAtomicSetPtr(&d, (more...)