[gnutls-devel] GnuTLS | priority: rework config reloading logic and locking (!1483)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Tue Nov 2 15:54:17 CET 2021




Daiki Ueno commented on a discussion on lib/priority.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1483#note_721209729

>  			 * allow it to be updated without restarting
>  			 * all applications
>  			 */
> +			GNUTLS_STATIC_MUTEX_LOCK(system_wide_config_mutex);
>  			_gnutls_update_system_priorities();

That's a good point and I haven't thought about it; thanks.

If we move the call out of the loop, I suppose the code will look like:
```c
// lock
_gnutls_update_system_priorities();
do {
  ...
  p = name_val_array_value(system_wide_priority_strings, ss, ss_len);
  ... // use p
} while (ss && ret == NULL);
// unlock
```
I think this expands the critical section unnecessarily.

If we could use RW lock, it could be written like:
```c
// wrlock
_gnutls_update_system_priorities();
// unlock
do {
  ...
  // rdlock
  p = name_val_array_value(system_wide_priority_strings, ss, ss_len);
  ... // use p
  // unlock
} while (ss && ret == NULL);
```

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1483#note_721209729
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20211102/7da6526d/attachment.html>


More information about the Gnutls-devel mailing list