diff options
author | Carl Baldwin <carl@ecbaldwin.net> | 2019-10-11 13:11:44 -0600 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2019-10-15 20:21:18 +0900 |
commit | 65929fe5245f715322286f683cbcf3d15699e8b4 (patch) | |
tree | ecc0962196b84e1d43f15a5b8b1c65a70b710c85 /pkg/server | |
parent | ea87564b5b5d332ab48b6619c4a365559111e2c9 (diff) |
Keep Lock and defer Unlock together
The best way to ensure that a lock will always get unlocked is to
defer the unlock immediately after locking. Otherwise, adding a return
statement in the middle somewhere *could* result in forgetting to
release the lock. One of these two cases has that.
This technique uses an anonymous function/closure within the larger
method to confine the scope of the lock and ensure that it will be
unlocked in every case.
Diffstat (limited to 'pkg/server')
0 files changed, 0 insertions, 0 deletions