Skip to content
  • Michael Catanzaro's avatar
    Fix sporadic failures in PKCS#11 client auth test · 0a659d0a
    Michael Catanzaro authored
    This was hard. The problem was that the mock PKCS#11 module accepts only
    a single PKCS#11 session at a time. The test normally creates one
    session, closes it, creates another, and closes it. But sometimes the
    first session doesn't get closed before the second is created, and the
    test breaks. The problem is that the PKCS#11 session is created and
    closed by the GTlsClientConnection. The test creates two, and unrefs the
    first one before creating the second, but other refs are held by the
    first connection's GTasks. These GTasks complete in idle callbacks, and
    if one idle fails to run before we finish iterating the main loop, the
    first GTlsClientConnection won't be destroyed and so the first PKCS#11
    session won't be closed in time. Note there is no bug in the
    implementation, and nothing is leaked; rather, it's just not destroyed
    soon enough for the test.
    
    Fix this by iterating the test's main context until the first connection
    is destroyed.
    0a659d0a