1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-04 17:47:26 +03:00
Volker Lendecke 00513daf78 g_lock: Simplify g_lock_trylock
While chasing a bug in g_lock (not in master) I saw some opportunity to
simplify g_lock_trylock a bit. This is array handling, and array
handling is just extremely error-prone. This *might* be a little less
efficient or large numbers of READ locks, but this remains to be
seen. For now, simplify the code.

First, we make two passes now: One to remove ourselves, and the other
one to search for conflicts. Mixing up both made it pretty hard for me
to follow the code.

Second, I've removed the _mylock and mylock pointer/struct logic and
replaced it with the "mylock.pid.pid != 0 ? &mylock : NULL" when calling
g_lock_store. To me, this focuses the logic whether to add ourselves in
one place instead of spreading it around in the whole routine.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Aug 14 11:42:10 CEST 2018 on sn-devel-144
2018-08-14 11:42:10 +02:00
..
2012-03-24 17:11:11 +01:00
2018-07-24 20:36:49 +02:00
2018-05-12 02:09:26 +02:00
2017-10-20 20:03:12 +02:00
2016-07-28 05:00:18 +02:00
2018-08-14 11:42:10 +02:00
2017-05-10 15:53:20 +02:00
2017-02-15 02:28:16 +01:00
2017-01-22 18:30:11 +01:00
2017-11-29 16:59:16 +01:00
2015-11-06 13:43:45 +01:00
2015-10-13 01:23:07 +02:00
2017-12-05 04:58:26 +01:00
2018-07-24 20:36:50 +02:00
2018-07-24 20:36:50 +02:00
2016-02-23 22:03:16 +01:00
2016-02-23 22:03:16 +01:00
2015-02-13 23:32:07 +01:00
2016-02-23 22:03:16 +01:00
2015-03-17 11:30:52 +01:00
2017-01-22 18:30:11 +01:00
2012-04-17 10:21:02 +02:00
2012-07-18 15:54:20 -07:00
2018-02-20 21:55:13 +01:00
2012-05-15 18:24:10 +02:00
2016-12-28 20:17:12 +01:00
2016-01-10 22:24:17 +01:00
2016-01-10 22:24:17 +01:00
2016-12-28 20:17:13 +01:00