mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 22:15:23 +00:00
[947-mt-compatibility-for-hooks] Checkpoint: hook library done, hooks to do
This commit is contained in:
committed by
Razvan Becheriu
parent
499e09cb45
commit
f241cdd7c4
@@ -274,15 +274,22 @@ erver multi-threading configuration. The value 0 means not compatible
|
|||||||
and is the default when the function is not implemented. not 0 values
|
and is the default when the function is not implemented. not 0 values
|
||||||
mean compatible.
|
mean compatible.
|
||||||
|
|
||||||
|
If your code implements it and returns the value 0 it is recommended
|
||||||
|
to document the reason so someone revisiting the code will not by
|
||||||
|
accident change the code.
|
||||||
|
|
||||||
To be compatible means:
|
To be compatible means:
|
||||||
- the code associated with DHCP packet processing callouts e.g.
|
- the code associated with DHCP packet processing callouts e.g.
|
||||||
pkt4_receive or pkt6_send must be reentrant so the multi-threaded DHCP service
|
pkt4_receive or pkt6_send must be thread safe so the multi-threaded
|
||||||
can simultaneously calls more than once on of these callouts.
|
DHCP service can simultaneously calls more than once on of these callouts.
|
||||||
- commands a library registers must be reentrant
|
- commands a library registers are not required to be thread safe because
|
||||||
- when a library implements a backend API (e.g. host data source) the service
|
commands are executed by the main thread. Now it is a good idea to make
|
||||||
methods must be reentrant
|
them thread safe and to document cases where they are not.
|
||||||
- (shall be modified later) a library must not modify the internal
|
- when a library implements a thread safe backend API (e.g. host data
|
||||||
configuration of the server, e.g. create or delete a subnet.
|
ource) the service methods must be thread safe.
|
||||||
|
- a library which modifies the internal configuration of the server,
|
||||||
|
e.g. create or delete a subnet, must enter a critical section using
|
||||||
|
the @c isc::dhcp::MultiThreadingCriticalSection RAII class.
|
||||||
|
|
||||||
In the tutoral, we'll put "multi_threading_compatible" in its own file,
|
In the tutoral, we'll put "multi_threading_compatible" in its own file,
|
||||||
multi_threading_compatible.cc. The contents are:
|
multi_threading_compatible.cc. The contents are:
|
||||||
@@ -299,6 +306,23 @@ int multi_threading_compatible() {
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
and for a command creating a new subnet:
|
||||||
|
|
||||||
|
@code
|
||||||
|
#include <dhcpsrv/multi_threading_utils.h>
|
||||||
|
|
||||||
|
int commandHandler(CalloutHandle& handle) {
|
||||||
|
...
|
||||||
|
{
|
||||||
|
// Enter the critical section.
|
||||||
|
MultiThreadingCriticalSection ct;
|
||||||
|
<add the subnet>
|
||||||
|
// Leave the critical section.
|
||||||
|
}
|
||||||
|
...
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
@subsection hooksdgCallouts Callouts
|
@subsection hooksdgCallouts Callouts
|
||||||
|
|
||||||
Having sorted out the framework, we now come to the functions that
|
Having sorted out the framework, we now come to the functions that
|
||||||
|
Reference in New Issue
Block a user