Skip to content

On kafka_topic_map_ and destructors #4

Description

@javierguerragiraldez

Hi.

As far as I can tell, the kafka_topic_map_ table is used only to relate the topics created with each producer, so that they can be destroyed before the producer. but:

  1. it uses the rd_kafka_t cdata object as the table key; but that's specifically advised against in the FFI docs:

Lua tables may be indexed by cdata objects, but this doesn't provide any useful semantics — cdata objects are unsuitable as table keys!

I guess in this specific case it's workable, since the only library function that returns a rd_kafka_t pointer is the creator, so there shouldn't be two different cdata objects with the same content. Still, it's a fragile situation.

  1. kafka_topic_map_ is a regular, strong, Lua table; so the rd_kafka_t cdata objects registered there won't be GC'ed, even if the producer Lua wrapper is collected. Effectively, it's made useless by its own existence.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions