Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-2181

Create debug log stream directly from php_open_temporary_fd result

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      The extension's module globals uses a FILE* for the debug log, despite the struct field being named "debug_fd" (we can consider renaming that as part of this ticket).

      In phongo_ini.c, we use php_open_temporary_fd to create a temporary file when needed. This returns an opened file descriptor and sets an output variable with the newly created file's path. We end up closing the file descriptor and opening a new stream with the path. Instead, we should consider converting the file descriptor to a stream using fdopen(3) (or _fdopen() on Windows) to be more efficient.

      For some added context on why we use FILE* instead of file descriptors: the log handler relies on fprintf(3), which takes a stream argument. Although dprintf(3) does exist for file descriptors, it's not nearly as portable.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: