On Wed, Jun 24, 2015 at 05:33:51PM +0300, Nikolay Shirokovskiy wrote:
1. Introduce connect(Un)RegisterCloseCallback driver functions.
2. virConnect(Un)RegisterCloseCallback now works through driver.
3. virConnectCloseCallback is factored from virConnect but mostly stay the
same. Notice however that virConnect object is not referenced in
virConnectCloseCallback anymore. It is safe. Explanation.
Previous version of callback object keeps reference to connection. This leads
to undocumented rule that all clients must exlicitly unregister close callback
before closing connection or connection will never be disposed. As callback
unregistering and close event delivering are serialized thru callback object
lock and unregistering zeros connection object we will never get dangling
pointer on delivering.
4. callback object doesn't check callback on unregistering. The reason is that
it will helps us write registering/unregistering with atomic behaviour for
remote driver as it can be seen in next patch. Moreover it is not really
meaningful to check callback on unregistering.
5. virNetClientSetCloseCallback call is removed from doRemoteClose as it is
excessive for the same reasons as in point 3. Unregistering MUST be called
and this prevents from firing event on close initiated by client.
I'm not sure where callback object should be so it stays in datatype.c
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/datatypes.c | 112 +++++++++++++++++++++++++++++++++-----------
src/datatypes.h | 21 ++++++--
src/driver-hypervisor.h | 12 +++++
src/libvirt-host.c | 79 ++++++++++---------------------
src/remote/remote_driver.c | 67 ++++++++++++++++----------
5 files changed, 179 insertions(+), 112 deletions(-)
Lots of spurious whitespace changes, some of them make the commit very
messy and make syntax-check fails again after this.
Martin