]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[947-mt-compatibility-for-hooks] Did a first pass on core hooks
authorFrancis Dupont <fdupont@isc.org>
Thu, 7 Nov 2019 00:38:38 +0000 (01:38 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 7 Nov 2019 00:38:38 +0000 (01:38 +0100)
src/hooks/dhcp/flex_option/flex_option.dox
src/hooks/dhcp/flex_option/flex_option_callouts.cc
src/hooks/dhcp/high_availability/ha.dox
src/hooks/dhcp/high_availability/ha_callouts.cc
src/hooks/dhcp/lease_cmds/lease_cmds.cc
src/hooks/dhcp/lease_cmds/lease_cmds.dox
src/hooks/dhcp/lease_cmds/lease_cmds_callouts.cc
src/hooks/dhcp/mysql_cb/mysql_cb_callouts.cc
src/hooks/dhcp/stat_cmds/stat_cmds.dox
src/hooks/dhcp/stat_cmds/stat_cmds_callouts.cc
src/hooks/dhcp/user_chk/libdhcp_user_chk.dox

index 59e8beccc7e535e184beef3f55127dcb89684bc4..826f7e5498eb0c0c205fdfa075c3904fc4a09e73 100644 (file)
@@ -112,4 +112,8 @@ applied by the template @ref process located in flex_option.h. When
 required the expression is evaluated on the query packet and the result
 is used by the action for instance to add a new option.
 
+@section libdhcp_flex_optionMTCompatibility Multi-Threading Compaibility
+
+The libdhcp_flex_option hooks library is compatible with multi-threading.
+
 */
index 2122de6a72d711cd26d5096204f59fe883c9611d..2f3f88dd946f5aea55bb3fa0f2572ef584693a0f 100644 (file)
@@ -122,4 +122,11 @@ int unload() {
     return (0);
 }
 
+/// @brief This function is called to know the multi-threading compatibility.
+///
+/// @return 1 which means compatible with multi-threading.
+int multi_threading_compatible() {
+    return (1);
+}
+
 } // end extern "C"
index 6cffa2743d5e7d76e39d5fd526a69292bb7e830e..f905c135c408daca5e8309a0977164863d3c2b2f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -407,4 +407,10 @@ Addressing this issue requires two enhancements:
   points via which the server removing the lease from the database could
   notify the partner about such removal.
 
+@section haMTCompatibility Multi-Threading Compatibility
+
+The High Availability hooks library currently reports it is not
+compatible with multi-threading. This will be revisited as there is
+no essential reason for such uncompatibility.
+
 */
index 6dcdeac3ebce251275bdcf149b0a6413dabb8a7e..9a451aa83870f85483cc5b43560ddf23154ff120 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -241,5 +241,14 @@ int unload() {
     return (0);
 }
 
+/// @brief This function is called to know the multi-threading compatibility.
+///
+/// @note: this should be revisited as the library is not essentially
+/// uncompatible.
+///
+/// @return 0 which means not compatible with multi-threading.
+int multi_threading_compatible() {
+    return (0);
+}
 
 } // end extern "C"
index 240c68ee6ca9310f8b1155a45f3dab7f309d990f..35b83dd03afd06a2a573de48c6f3d4a503242253 100644 (file)
@@ -14,6 +14,7 @@
 #include <dhcpsrv/dhcpsrv_exceptions.h>
 #include <dhcpsrv/lease_mgr.h>
 #include <dhcpsrv/lease_mgr_factory.h>
+#include <dhcpsrv/multi_threading_utils.h>
 #include <dhcpsrv/subnet_id.h>
 #include <dhcpsrv/sanity_checker.h>
 #include <dhcp/duid.h>
@@ -1564,19 +1565,23 @@ LeaseCmdsImpl::createFailedLeaseMap(const Lease::Type& lease_type,
     return (failed_lease_map);
 }
 
+// Do lease changes in a critical section.
+
 int
 LeaseCmds::leaseAddHandler(CalloutHandle& handle) {
-    return(impl_->leaseAddHandler(handle));
+    MultiThreadingCriticalSection cs;
+    return (impl_->leaseAddHandler(handle));
 }
 
 int
 LeaseCmds::lease6BulkApplyHandler(CalloutHandle& handle) {
+    MultiThreadingCriticalSection cs;
     return (impl_->lease6BulkApplyHandler(handle));
 }
 
 int
 LeaseCmds::leaseGetHandler(CalloutHandle& handle) {
-    return(impl_->leaseGetHandler(handle));
+    return (impl_->leaseGetHandler(handle));
 }
 
 int
@@ -1611,32 +1616,38 @@ LeaseCmds::leaseGetByHostnameHandler(hooks::CalloutHandle& handle) {
 
 int
 LeaseCmds::lease4DelHandler(CalloutHandle& handle) {
-    return(impl_->lease4DelHandler(handle));
+    MultiThreadingCriticalSection cs;
+    return (impl_->lease4DelHandler(handle));
 }
 
 int
 LeaseCmds::lease6DelHandler(CalloutHandle& handle) {
-    return(impl_->lease6DelHandler(handle));
+    MultiThreadingCriticalSection cs;
+    return (impl_->lease6DelHandler(handle));
 }
 
 int
 LeaseCmds::lease4UpdateHandler(CalloutHandle& handle) {
-    return(impl_->lease4UpdateHandler(handle));
+    MultiThreadingCriticalSection cs;
+    return (impl_->lease4UpdateHandler(handle));
 }
 
 int
 LeaseCmds::lease6UpdateHandler(CalloutHandle& handle) {
-    return(impl_->lease6UpdateHandler(handle));
+    MultiThreadingCriticalSection cs;
+    return (impl_->lease6UpdateHandler(handle));
 }
 
 int
 LeaseCmds::lease4WipeHandler(CalloutHandle& handle) {
-   return(impl_->lease4WipeHandler(handle));
+    MultiThreadingCriticalSection cs;
+    return (impl_->lease4WipeHandler(handle));
 }
 
 int
 LeaseCmds::lease6WipeHandler(CalloutHandle& handle) {
-   return(impl_->lease6WipeHandler(handle));
+    MultiThreadingCriticalSection cs;
+    return (impl_->lease6WipeHandler(handle));
 }
 
 LeaseCmds::LeaseCmds()
index 8afbc1107cec03039638885fc29c1d6b80209b33..b12f71dcc2439068d8ea16079b6cf925901236c1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -95,4 +95,10 @@ commands that remove all leases from specific subnet. As there were no
 queries that could retrieve or otherwise enumerate leases for a specific subnet,
 a new query type and a new index had to be added.
 
+@section lease_cmdsTCompatibility Multi-Threading Compatibility
+
+The Lease Commands Hook library is compatible with multi-threading.
+All commands modifying leases are performed inside a critical section
+i.e. with the DHCP server stopped.
+
 */
index 1b28e4615e1d4aa269c0537d15988511e545565a..02c1ec35fc4c3fc098d8b5f926f9c61c05029c11 100644 (file)
@@ -284,4 +284,11 @@ int unload() {
     return (0);
 }
 
+/// @brief This function is called to know the multi-threading compatibility.
+///
+/// @return 1 which means compatible with multi-threading.
+int multi_threading_compatible() {
+    return (1);
+}
+
 } // end extern "C"
index 11b11df7262cf19787b459cfc3dd75e460257f03..7140621b6b3a5fef9c30d343321fd87765d3d656 100644 (file)
@@ -45,5 +45,14 @@ int unload() {
     return (0);
 }
 
+/// @brief This function is called to know the multi-threading compatibility.
+///
+/// @note: the compatibility is based on the assumption this hook library
+/// is always called from the main thread.
+///
+/// @return 1 which means compatible with multi-threading.
+int multi_threading_compatible() {
+    return (1);
+}
 
 } // end extern "C"
index 8480cff276516813592f72ae7605b7237a6d66a0..e267e3c35055c48d611603621c8f8dbd6d9f6e5d 100644 (file)
@@ -196,4 +196,10 @@ and DHCPv6 response might look like this:
         }
 @endcode
 
+@section stat_cmdsMTCompatibility Multi-Threading Compatibility
+
+The Stat Commands Hook library currently reports it is not
+compatible with multi-threading. This will be revisited as there is
+no essential reason for such uncompatibility.
+
 */
index be210486e57330a36337ce980e678e6e612a3209..c4afeaeab9b7f5377d319f8aa7b134c6c0a02607 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the End User License
 // Agreement. See COPYING file in the premium/ directory.
@@ -61,4 +61,14 @@ int unload() {
     return (0);
 }
 
+/// @brief This function is called to know the multi-threading compatibility.
+///
+/// @note: this should be revisited as the library is not essentially
+/// uncompatible.
+///
+/// @return 0 which means not compatible with multi-threading.
+int multi_threading_compatible() {
+    return (0);
+}
+
 } // end extern "C"
index 4cf6a42383f0e53b6272167c8f6919bf17504372..4b3534252ab41d383d8d3cdcd3291fa10af48eab 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -212,6 +212,10 @@ registered=yes
 
 Note the library always opens this file in append mode and does not limit its size.
 
+@section libdhcp_user_chkMTCompatibility Multi-Threading Compaibility
 
+The user_chk hooks library does not define a multi_threading_compatible()
+C function so is considered as not compatible with multi-threading
+(and the current code should be in fact really not compatible).
 
 */