obexd: Add handing of backend pending request
Add phonebook_req_finalize function prototype in phonebook.h that
deallocates resources associated to asynchronous request, and
cancels the request if it is not completed. It unrefs pointer to
pending request if such is applicable.
It does the following, depending on phonebook backend:
- for phonebook-tracker.c backend driver, it cancels pending DBus call,
- for phonebook-dummy.c, it removes GSource with a given id,
- for phonebook-ebook.c, it cancels last, still running, asynchronous
operation.
The following modifcations are donein the code. Phonebook request
pointer is added in PBAP object and IRMC session data to provide
reference for pending call. Phonebook callbacks are updated in PBAP
and IRMC to unref request upon completion and clear pointers, if such
is applicable.
PBAP and IRMC are updated to cancel pending request, if any, when OBEX
object is closed.
Phonebook_pull, phonebook_get_entry, phonebook_create_cache functions
are updated to return void pointer to backend specific request and error
code. All backend drivers updated accordingly to the modified API, which
are phonebook-tracker.c, phonebook-dummy.c, and phonebook-ebook.c, to be
specific.
In phonebook-tracker.c, query_tracker is updated to return pending DBus
call request. Allocated pending_reply and phonebook_data are destroyed
after call is unrefed. For this purpose new query_free_data function is
created.
Call is unrefed either if request succeeded or in
phonebook_req_finalize if terminated.
Such fix prevents obexd crash on unexpected OBEX session close. E.g.,
OBEX session is closed before reply comes from phonebook backend. In
that case, both session and object are destroyed, and dereferencing of
object in associated callback function causes crash.
6 files changed