Skip to content

Commit a1c10d9

Browse files
authoredFeb 6, 2023
Release 1.7.0 (#137)
1 parent d57d6fb commit a1c10d9

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed
 

‎CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# libddwaf release
22

3+
### v1.7.0 ([unstable](https://github.com/DataDog/libddwaf/blob/master/README.md#versioning-semantics)) - 2023/02/06
4+
#### Changes
5+
- Handle lifetime extension ([#135](https://github.com/DataDog/libddwaf/pull/135))
6+
- Create macos universal binary ([#136](https://github.com/DataDog/libddwaf/pull/136))
7+
38
### v1.6.2 ([unstable](https://github.com/DataDog/libddwaf/blob/master/README.md#versioning-semantics)) - 2023/01/26
49
#### Changes
510
- Add boolean getter ([#132](https://github.com/DataDog/libddwaf/pull/132))

‎UPGRADING.md

+28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Upgrading libddwaf
22

3+
### Upgrading from `1.6.x` to `1.7.0`
4+
5+
There are no API changes in 1.7.0, however `ddwaf_handle` is now reference-counted and shared between the user and each `ddwaf_context`. This means that it is now possible to call `ddwaf_destroy` on a `ddwaf_handle` without invalidating any `ddwaf_context` in use instantiated from said `ddwaf_handle`. For example, the following snippet is now perfectly legal and will work as expected (note that any checks have been omitted for brevity):
6+
7+
```c
8+
ddwaf_handle handle = ddwaf_init(&rule, &config, NULL);
9+
ddwaf_object_free(&rule);
10+
11+
ddwaf_context context = ddwaf_context_init(handle);
12+
13+
// Destroying the handle should not invalidate the context
14+
ddwaf_destroy(handle);
15+
16+
...
17+
18+
ddwaf_run(context, &parameter, NULL, LONG_TIME);
19+
20+
// Both the context and the handle are destroyed here
21+
ddwaf_context_destroy(context);
22+
```
23+
24+
To expand on the example above:
25+
- `ddwaf_destroy` only destroys the `ddwaf_handle` if there are no more references to it, otherwise it relinquishes ownership to the rest of the contexts.
26+
- If there is more than one valid context after the user calls `ddwaf_destroy`, each context will reduce the reference count on `ddwaf_context_destroy` until it reaches zero, at which point the `ddwaf_handle` will be freed.
27+
- Once the user calls `ddwaf_destroy` on the `ddwaf_handle`, their reference becomes invalid and no more operations can be performed on it, including instantiating further contexts.
28+
29+
Note that this doesn't make `ddwaf_handle` universally thread-safe, for example, replacing an existing `ddwaf_handle` shared by multiple threads still requires synchronisation.
30+
331
## Upgrading from `v1.4.0` to `1.5.0`
432
533
### Actions

‎tests/TestInterface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ TEST(FunctionalTests, HandleBad)
296296
/*ddwaf_destroy(handle2);*/
297297
/*}*/
298298

299-
TEST(FunctionalTests, ddwaf_get_version) { EXPECT_STREQ(ddwaf_get_version(), "1.6.2"); }
299+
TEST(FunctionalTests, ddwaf_get_version) { EXPECT_STREQ(ddwaf_get_version(), "1.7.0"); }
300300

301301
TEST(FunctionalTests, ddwaf_runNull)
302302
{

‎version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.2
1+
1.7.0

0 commit comments

Comments
 (0)
Please sign in to comment.