bus: improve user quota accounting and domain locking
authorDjalal Harouni <tixxdz@opendz.org>
Wed, 30 Jul 2014 20:11:56 +0000 (21:11 +0100)
committerKay Sievers <kay@vrfy.org>
Thu, 31 Jul 2014 14:29:57 +0000 (16:29 +0200)
commit1ee9fcac431e4d6f71a7667258e343459a13e5c7
treeecfd5df0fe0c6cfe8222fa063f93aca6f9cad35c
parente8c7fddfb695c384c6ecfdd15b3066480f473a45
bus: improve user quota accounting and domain locking

Currently kdbus_bus_new() execution path might take the domain lock
three times on success, four times on failure.

kdbus_bus_new():
  => kdbus_domain_user_find_or_new(): takes it 2 times (and it is racy)
  +
  kdbus_bus_new(): take it an extra time to account the user and link
  the bus into the domain bus_list.

And as discussed in the previous patch kdbus_domain_user_find_or_new()
is racy, so convert to __kdbus_domain_user_account()

This allows also to improve the execution path to take the domain lock
only one time in case of success. On failure the domain lock will be
taken two times.

kdbus_bus_new():
  => take domain lock
  => check if domain is still active/connected
     => __kdbus_domain_user_account()
  ...

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
bus.c