Conversation
1afd92f to
f892240
Compare
f892240 to
046ffb5
Compare
test: dns - add expected addr list
cbad667 to
c80326d
Compare
| struct le *le = mem_zalloc(sizeof(*le), NULL); | ||
| if (!le) | ||
| return true; | ||
|
|
||
| list_append(lst, le, mem_ref(rr)); |
There was a problem hiding this comment.
This could be added to a new list function. E.g. list_append_ref(lst, data).
The struct le could get a flag to know if list_flush() should also deref the le.
Edit: What do you think?
There was a problem hiding this comment.
First let me know what you think about this: #1527
For now I set this to draft.
|
The While the code is inside the DNS callback handler, the RR entries should be valid. Perhaps it would be a solution to clone the RR entry ? |
|
Yes maybe a: struct dnsrr *rrdup = dns_rr_dup(rr);
...
list_append(lst, &rrdup->le, rrdup);would be much nicer. |
|
Oh, there happened something in parallel. @maximilianfridrich and me discussed currently and would suggest this solution: #1525 In general this should be possible list_append(lst, le, mem_ref(data));But the user of Edit: Anyway, if you prefer the deep copy. We could proceed here: #1512. Just let us know! |
|
As mentioned by @alfredh a So this could be the fix: --- a/src/sip/request.c
+++ b/src/sip/request.c
@@ -384,7 +384,8 @@ static bool rr_append_handler(struct dnsrr *rr, void *arg)
if (rr->le.list)
break;
- list_append(lst, &rr->le, mem_ref(rr));
+ struct dnsrr *rrdup = dns_rr_dup(rr);
+ list_append(lst, &rrdup->le, rrdup);
break;
}Or instead of a deep static bool rr_handler(struct dnsrr *rr, void *arg)
{
struct http_req *req = arg;
if (req->srvc >= RE_ARRAY_SIZE(req->srvv))
return true;
switch (rr->type) {
case DNS_TYPE_A:
sa_set_in(&req->srvv[req->srvc++], rr->rdata.a.addr,
req->port);
break;
case DNS_TYPE_AAAA:
sa_set_in6(&req->srvv[req->srvc++], rr->rdata.aaaa.addr,
req->port);
break;
}
return false;
} |
|
If a simpler dns_rrlist_sort_addr(&req->addrl, req->sortkey); |
|
Thanks for the reviews and feedback! Since the duplication/copying solution is preferred, I implemented the |
There are situations where multiple references of the same
rrobject are used at different places. E.g. in two SIP requests that are sent in parallel.This PR adds a test of this use case.
Another PR that fixes request.c will follow.
Then
dnsrr->lebecomes obsolete and can be removed.