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

VSB_tofile() not public in libvarnishapi.so #3238

Closed
slimhazard opened this issue Mar 2, 2020 · 13 comments
Closed

VSB_tofile() not public in libvarnishapi.so #3238

slimhazard opened this issue Mar 2, 2020 · 13 comments

Comments

@slimhazard
Copy link
Contributor

VSB_tofile() has been around since cf14a0f, but:

$ nm libvarnishapi.so.2.0.0 | grep tofile
000000000000a790 t VSB_tofile

The lowercase t meaning not global, so it can't be used from a VMOD or utility that just links to libvarnishapi.

Is that intentional? I suspect that adding it to libvarnishapi.map may have been forgotten.

@bsdphk
Copy link
Contributor

bsdphk commented Mar 2, 2020

As far as I know, it is not intentional.

@nigoroll
Copy link
Member

nigoroll commented Mar 2, 2020

bugwash:

  • start LIBVARNISHAPI_2.4
  • review if anything else is missing
  • add missing symbols

@Dridi
Copy link
Member

Dridi commented Mar 4, 2020

I didn't find anything missing, but I think I found a spurious entry:

VCLI_WriteResult doesn't look like something a libvarnishapi client would have any business calling. For this reason, I'm not worried about breaking the ABI since this should be a false-positive, similar to the VRT vs VPI situation. Correct me if I'm wrong, but I have a patch ready that adds VSB_tofile and removes VCLI_WriteResult. All I need is a confirmation for the latter.

@slimhazard
Copy link
Contributor Author

Agree that VCLI_WriteResult doesn't make sense in a client API.

@Dridi
Copy link
Member

Dridi commented Mar 4, 2020

@slimhazard I'm surprised though that you can't use it in a VMOD. It's available via libvarnish, so if you link against varnishd and varnishd uses VSB_tofile (and it does) then your VMOD should be able to link it as well.

@Dridi Dridi closed this as completed in c22ccdc Mar 4, 2020
@slimhazard
Copy link
Contributor Author

@Dridi sure, if it's a VMOD, and once you get Varnish to load the VMOD. So I may have been wrong about VMODs, but I had tried it with a client app.

I'm not sure if a VMOD build can get past the ld step if it depends on a symbol in libvarnish.so. Unless you put libvarnish.so into the linker path, and then you're into source-dependent builds.

At any rate, I think making $ABI vrt and libvarnishapi.so as friendly as possible to VMOD authors is in the best interest of the project.

This is an area where I think there's a need for clarity. It confuses me when I see something in the Varnish /usr/include or /usr/local/include headers, but the symbols aren't public -- those are known as "public include paths", after all. If it's in there, I assume that my client is allowed to use it, but that doesn't seem to guide the actual thinking of the project.

@Dridi
Copy link
Member

Dridi commented Mar 4, 2020

I definitely agree that public includes could better be curated, and it has been incrementally improved release after release.

@Dridi
Copy link
Member

Dridi commented Mar 5, 2020

Reopening because I have a question before VSB_tofile() becomes part of the public API: why is it the only VSB_*() function that doesn't take a VSB as its first argument?

@slimhazard
Copy link
Contributor Author

Just to comment that although I opened the ticket, it's probably @bsdphk who can answer the question.

If I had to guess, I'd say it's following the style of a lib call like write(2) that has an int fd as the first arg and a *buf as the next arg.

@nigoroll
Copy link
Member

nigoroll commented Mar 8, 2020

@Dridi I do not know the answer to why but I think the different signature makes sense: The other VSB function do something to the VSB, this one does something with the VSB. The exception to this rule are VSB_error(), VSB_data() and VSB_len(), but they only take one const argument.

@bsdphk
Copy link
Contributor

bsdphk commented Mar 9, 2020

You both got a point.

As a general rule (with many exceptions!) in C-land one should start out with the function arguments which change state.

On the other hand, in OO-ish-C, the first argument should consistently be the 'self/this' argument.

Given how VSB tries hard to isolate the internals, we should probably lean the OO direction and make vsb the first argument.

@Dridi
Copy link
Member

Dridi commented Mar 9, 2020

Nobody really argued one way or the other. I asked, and Zejerman formulated hypotheses.

If we need to make a decision, it needs to happen "fast", and fwiw I would lean towards the OO direction.

@slimhazard
Copy link
Contributor Author

+-0 for either way, flip a coin or go with OO, since some of us are leaning that way. #bikeshed

@Dridi Dridi closed this as completed in 20c8aaf Mar 11, 2020
andrewwiik pushed a commit to ioscreatix/varnish-cache that referenced this issue Apr 1, 2020
Closes varnishcache#3238

Conflicts:
    lib/libvarnishapi/libvarnishapi.map
andrewwiik pushed a commit to ioscreatix/varnish-cache that referenced this issue Apr 1, 2020
Automated with Coccinelle, so the semantic patch could be reused in the
vtest project.

Closes varnishcache#3238

Conflicts:
    lib/libvcc/vcc_compile.c
    bin/varnishd/proxy/cache_proxy_proto.c
rezan pushed a commit that referenced this issue May 19, 2020
Closes #3238

Conflicts:
    lib/libvarnishapi/libvarnishapi.map
rezan pushed a commit that referenced this issue May 19, 2020
Automated with Coccinelle, so the semantic patch could be reused in the
vtest project.

Closes #3238

Conflicts:
    lib/libvcc/vcc_compile.c
    bin/varnishd/proxy/cache_proxy_proto.c
hermunn pushed a commit to hermunn/varnish-cache that referenced this issue Nov 3, 2020
Closes varnishcache#3238

Conflicts:
    lib/libvarnishapi/libvarnishapi.map
hermunn pushed a commit to hermunn/varnish-cache that referenced this issue Nov 3, 2020
Automated with Coccinelle, so the semantic patch could be reused in the
vtest project.

Closes varnishcache#3238

Conflicts:
    lib/libvcc/vcc_compile.c
    bin/varnishd/proxy/cache_proxy_proto.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants