In the method `acquire_spi`, the condition of acquiring and releasing is not aligned. It seems the lock would be acquired but released only when `spi_data->spi_val == initial_val`, Would it lead to missing lock release? https://github.com/kamailio/kamailio/blob/1ddc27f199061025a6a43da3e8a1388fca... https://github.com/kamailio/kamailio/blob/1ddc27f199061025a6a43da3e8a1388fca...
In the method `release_spi`, the lock may be re-acquired so missing lock release in the method `acquire_spi` could lead to a deadlock. https://github.com/kamailio/kamailio/blob/1ddc27f199061025a6a43da3e8a1388fca...