A few weeks ago I have been working with the libgalago library by Christian Hammond. If you don’t know what is libgalago take a look at this article of the Linux Journal. Basically galago is a library that provides presence to applications. This library had a little performance issue. libgalago uses DBUS for getting/setting presences, and all the calls through the bus were synchronous. Imagine a device with low resources, for example the Nokia 770, that uses libgalago. It could be that if you have a lot of contacts, an application that uses libgalago could get stalled due to it should wait for every call to the bus that requests for presences, contacts, services …etc.

I implemented an asynchronous implementation of three common libgalago calls:

  • galago_get_service
  • galago_service_get_account
  • galago_account_get_presence

These new asynchronous calls created new race conditions, because they could need some data that could be freed before the call to the function was made. So it made sense to implement another function galago_cancel_call that cancels an asynchronous call.

I sent the patch to Christian Hammond and he accepted it. It seems that he thought that it could be very interesting to add more asynchronous calls in the future, so he made some refactoring in the library code instead of applying the patch directly. Now you can use the asynchronous calls of libgalago because these changes are merged in the HEAD of the libgalago repository.

Happy presence :)