Retain callback procs for the lifetime of the parser

JRuby's FFI does not retain Ruby references to procs assigned into
FFI::Struct callback fields. The procs assigned into LLHttp::Callbacks
were referenced nowhere else, so on JRuby they became garbage as soon as
Parser#initialize returned. Once the JVM collected them, their native
trampolines were reclaimed and llhttp_execute would complete
successfully without invoking any callbacks, silently producing an
unparsed result.

Keep an explicit reference to each callback proc on the parser instance
so the trampolines live exactly as long as the parser that owns them.
MRI is unaffected (its FFI already retains struct-assigned procs).
1 file changed
tree: 03ccb6aa083cf571cfc6b2ddb9f584d99863def7
  1. .commit/
  2. .github/
  3. benchmarks/
  4. ffi/
  5. mri/
  6. spec/
  7. .editorconfig
  8. .gitignore
  9. .standard.yml
  10. Gemfile
  11. README.md
README.md

llhttp

Ruby bindings for llhttp.

This is a monorepo that includes projects for MRI and FFI. Generally speaking, you should prefer the MRI version and fallback to the FFI version for better compatibility. There is parity between the two implementations, but the MRI implementation is more performant.