Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4280

Clean up handshake-related test and implementation code

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: libmongoc
    • None

      In the process of adding server versioned API implementation and tests, it was observed that there are a number of inconsistencies involving the related code where there were inconsistent or redundant implementations. Consider that the following changes would reduce cognitive load and make the implementation more consistent and clear:

      • There are several instances of string literal "hello" and "helloOk" being used throughout both implementation and test code that could be replaced with the macros in mongoc-handshake-private.h (HANDSHAKE_CMD_LEGACY_HELLO, HANDSHAKE_RESPONSE_LEGACY_HELLO, HANDSHAKE_CMD_HELLO, and HANDSHAKE_RESPONSE_HELLO).
      • _server_monitor_send_and_recv_hello_opmsg and _server_monitor_send_and_recv_opquery are completely identical in all respects except for the initialization of RPC data. Consider refactoring the two functions such that initialization of RPC data for OP_MSG vs. OP_QUERY is handled separately from the actual "send and recv" implementation. (Related: see implementation of _mongoc_async_cmd_init_send.)
      • mock_server_receives* have naming conventions that doesn't reflect their purpose. Make this more clear, or consolidate the project's implementation ("https://github.com/mongodb/mongo-c-driver/pull/930/files#r808180970").
      • _mock_server_receives_single_msg() appears to be redundant; see if it can be removed with tests passing. See this thread for context.
      • We also have a number of different ways that we "freehand" construct or piecewise construct handshakes and responses-- an audit cataloguing them and consolidating them into straightforward functions would have been very helpful.
      • In "src/libmongoc/src/mongoc/mongoc-rpc.c" _mongoc_rpc_reply_get_first_msg(), we have a discrepancy between int32_t and BSON_UINT32_FROM_LE(). This can (and should) be resolved.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jesse.williamson@mongodb.com Jesse Williamson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: