Kindly focus only on cds_cancel_primitives. Thats the only change from Chetna's PR. Due to some git issues, the whole commit seems to be written by me. 
I would try to solve this thing but for the time being I would be really happy if you could only see the aforementioned function.