Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-51770

generalize errnoWithDescription to handle <system_error> categories

    • Fully Compatible
    • Service Arch 2022-03-21

      (split from SERVER-41353)

      Errors from different number spaces are being conflated and misreported. Fortunately C++11 has a solution to this problem. We should be using <system_error> to propagate error categories when we capture errno-style results into C++ with type safety.

      This should be a simple but repetitive change affecting places where we encounter system API errors and try to log them.

      Then something like errnoWithDescription (which would be renamed) can be assured to give correct results. Windows has POSIX errno AND it also has its own number spaces like the GetLastError DWORD errors. Other APIs in Linux and Windows will introduce their own number spaces, asio, libresolv, openssl, even mongodb itself.

      SERVER-41353 would introduce a wrapper to capture the code properly with number-space to associate the integer with a category context when it is captured.

      I'm not sure if this ticket and SERVER-41353 can be done separately. SERVER-41353 is more about the immediacy of copying errno/GetLastError before logging statements begin. This one, maybe as follow-up work, or maybe simultaneously, would be more about making sure the captured integers are interpreted properly. It's more about the implementation of errnoWithDescription, and renaming it.
      *Acceptance criteria: * Create an alternative to errnoWithDescription that takes a std::error_code.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: