Skip to content

semantics(connection): close() on one wrapper disconnects siblings sharing a non-persistent DSN-cached entry #579

Description

@satwareAG-ironMike

Summary

Pre-existing semantic quirk surfaced during the #576 review (PR #577), explicitly deferred there as out of scope. Memory-safe since #577; this is about close() semantics for shared non-persistent connections.

fbird_connect() deduplicates connections per DSN via the EG(regular_list) hash cache (_php_fbird_connect_link, reuse path). Two Firebird\Connection objects created for the same DSN therefore wrap one resource entry:

$a = fbird_connect($dsn);
$b = $driver->connect($dsn);   // same underlying entry (cache reuse)
$a->close();                    // fires the link dtor -> server link CLOSED
$b->isConnected();               // false - silently disconnected

Old behavior had the same observable effect (non-plink branch always zend_list_close), so nothing regressed in #577 - but with owned refs we now have the machinery to define better semantics.

Questions to answer

  1. Should closing one of several wrappers sharing an entry disconnect the others? (Current + legacy answer: yes.)
  2. Reference semantics of PDO_Firebird / other PHP DB exts: most treat each connection handle as independent (no DSN dedup for non-persistent links).
  3. Options:
    • a) Keep current behavior, document it ("close() closes the shared server link")
    • b) Per-wrapper logical handles over one physical link (refcounted close: last wrapper closes) - larger change
    • c) Disable non-persistent DSN dedup (each connect = own entry) - changes perf characteristics, aligns with other extensions

Related

Acceptance criteria

  1. Documented decision (docs note at minimum)
  2. If changed: regression phpt covering two-object share + close order permutations

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions