Have camel_session_list_services() return new references.
authorMatthew Barnes <mbarnes@redhat.com>
Sun, 12 Aug 2012 13:11:08 +0000 (09:11 -0400)
committerMatthew Barnes <mbarnes@redhat.com>
Sun, 12 Aug 2012 13:11:08 +0000 (09:11 -0400)
commitf5ae84279d39752897df0f3213e34165d50e582d
treeb6b074a4b8d05a3e543b48d39b64a7d9b482d022
parentfb2fb46f2ba430c3c16d07ad5eff1a292f1597b0
Have camel_session_list_services() return new references.

Applying lessons learned from ESourceRegistry.

When returning a pointer to a reference-counted object in a multi-
threaded environment, always increase the object's reference count
before returning so as to transfer a new reference to the caller.

Otherwise it introduces a potential race where the reference-counted
object may lose its last reference and be freed while the caller is
still using the object.  Even if the caller immediately increments
the object's reference count, it's still a potential race.

Transferring a new reference to the caller means the caller must
unreference the object when finished with it so the object will be
properly freed when it's no longer needed.

Making subtle behavioral changes like this without renaming the API
is usually considered bad, but since Evolution is the only consumer
we can easily keep the side-effects under control.
camel/camel-session.c