Currently the Port allocation code has been tested and now works with a high level of robustness. The things that were tested were as follows...
- Boundary Testing
- linked list loop and count verification
- randomness and out of order port allocation
The code now works so that a free port can always be found and allocated/deallocated in constant time. One interesting bug that I came across was when the tail of the list was attempted to be unallocated. Originally, the only check in place required to deallocate was that the port_node's next pointer was NULL. However this does not cover the case where the calling code tries to deallocate an already free node at the end of the linked list. By definition of a non-circular linked list, the last element should point to NULL. Therefore when this node is deallocated again, it will cause the LL node count to become off by 1, causeing a Segmentation fault.
Now that this code has been tested in a more robust manner, we can integrate it with the core MAR code.
No comments:
Post a Comment