Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vrt_vcl: Minor polish of director code #4241

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions bin/varnishd/cache/cache_vrt_vcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ VRT_Assign_Backend(VCL_BACKEND *dst, VCL_BACKEND src)
AN(dst);
CHECK_OBJ_ORNULL((*dst), DIRECTOR_MAGIC);
CHECK_OBJ_ORNULL(src, DIRECTOR_MAGIC);
if (*dst == src)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should just push this one to master

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return;
if (*dst != NULL) {
vdir = (*dst)->vdir;
CHECK_OBJ_NOTNULL(vdir, VCLDIR_MAGIC);
Expand Down Expand Up @@ -373,7 +375,7 @@ VRT_LookupDirector(VRT_CTX, VCL_STRING name)
{
struct vcl *vcl;
struct vcldir *vdir;
VCL_BACKEND dd, d = NULL;
VCL_BACKEND dir = NULL;

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(name);
Expand All @@ -386,15 +388,21 @@ VRT_LookupDirector(VRT_CTX, VCL_STRING name)

Lck_Lock(&vcl_mtx);
VTAILQ_FOREACH(vdir, &vcl->director_list, list) {
dd = vdir->dir;
if (strcmp(dd->vcl_name, name))
continue;
d = dd;
break;
if (!strcmp(vdir->dir->vcl_name, name)) {
dir = vdir->dir;
break;
}
}
Lck_Unlock(&vcl_mtx);

return (d);
/* XXX: There is a race here between the supposedly incoming call
* to VRT_Assign_Backend() and the next vcldir_deref() call.
*
* Maybe the VRT_CTX could keep a ref of the last director lookup
* that would linger until the end of vcl_init.
*/

return (dir);
}

/*--------------------------------------------------------------------*/
Expand Down
Loading