Bug 1913 - ub_ctx_config is under circumstances thread-safe
ub_ctx_config is under circumstances thread-safe
Status: RESOLVED FIXED
Product: unbound
Classification: Unclassified
Component: server
1.6.7
All Linux
: P5 enhancement
Assigned To: unbound team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-10-23 21:14 CEST by Дилян Палаузов
Modified: 2017-11-02 10:45 CET (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Дилян Палаузов 2017-10-23 21:14:28 CEST
https://www.unbound.net/documentation/libunbound.html says all functions are thread-safe and a context can be used in a threaded (as well as in a non-threaded) environment.  This implies that ub_ctx_config is thread-safe.  The latter calls util/config_file.c:config_read() which calls non-reentrant flex and non-pure bison parser.

If there is only one libunbound instance in an application, ub_ctx_config is thread-safe.  But if there are many instances, each calling ub_ctx_config at any time, as in opendkim...
Comment 1 Дилян Палаузов 2017-11-01 20:25:40 CET
I propose changing https://www.unbound.net/documentation/libunbound.html as follows:

current text:

ub_ctx_config
              A  power-user  interface that lets you specify an unbound config
              file, see unbound.conf(5), which is read for configuration.  Not
              all  options  are  relevant.  For some specific options, such as
              adding trust anchors, special routines exist.

new text:

ub_ctx_config
              A  power-user  interface that lets you specify an unbound config
              file, see unbound.conf(5), which is read for configuration.  Not
              all  options  are  relevant.  For some specific options, such as
              adding trust anchors, special routines exist.  This function is thread-save only if a single instance of ub_ctx* exists in the application,  If several instances exist the application has to ensure that ub_ctx_config is not called in parallel by the different instances.
Comment 2 Wouter Wijngaards 2017-11-02 09:25:34 CET
Hi,

Thank you for the text suggestion!  I have applied it to the source code, the web page you reference gets updated later.  So you won't be able to see it straight away.

Best regards, Wouter
Comment 3 Дилян Палаузов 2017-11-02 10:42:19 CET
Replace thread-save with thread-safe.

Moreover in the general description is written:

  The functions are thread\-safe, and a context ...

with slash before the dash but for ub_ctx_config it is without slash:

  routines exist.  This function is thread-save only if a single
Comment 4 Wouter Wijngaards 2017-11-02 10:45:45 CET
Hi,

Thanks, fixed that.  The escaped dashes are because of nroff processing and word-pyhenation rules; with the escape it won't move the dash somewhere else.

Best regards, Wouter