Skip to content

check SO_ERROR after nonblocking connect#158

Open
psumbera wants to merge 1 commit intoawesomized:v1.xfrom
psumbera:epipe
Open

check SO_ERROR after nonblocking connect#158
psumbera wants to merge 1 commit intoawesomized:v1.xfrom
psumbera:epipe

Conversation

@psumbera
Copy link

On Solaris, several memcached_errors tests failed because the client treated a nonblocking connect as successful as soon as poll/select reported the socket writable, then immediately attempted a send without first checking SO_ERROR. When the connect had actually failed, send() returned EPIPE, which libmemcached reported as MEMCACHED_SYSTEM_ERROR instead of MEMCACHED_CONNECTION_FAILURE. This change fixes the connect race by checking SO_ERROR in IO_POLL_CONNECT before declaring success, and also normalizes mid-connection write failures by mapping EPIPE/ENOTCONN/ECONNRESET to MEMCACHED_CONNECTION_FAILURE (marking the instance dead).

@psumbera
Copy link
Author

This is how test failed on Solaris:

/scratch/psumbera/userland-libmemcached/components/libmemcached/build/i86: ctest -R bin/memcat  -VV
UpdateCTestConfiguration  from :/scratch/psumbera/userland-libmemcached/components/libmemcached/build/i86/DartConfiguration.tcl
Parse Config file:/scratch/psumbera/userland-libmemcached/components/libmemcached/build/i86/DartConfiguration.tcl
UpdateCTestConfiguration  from :/scratch/psumbera/userland-libmemcached/components/libmemcached/build/i86/DartConfiguration.tcl
Parse Config file:/scratch/psumbera/userland-libmemcached/components/libmemcached/build/i86/DartConfiguration.tcl
Test project /scratch/psumbera/userland-libmemcached/components/libmemcached/build/i86
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 2
    Start 2: bin/memcat

2: Test command: /scratch/psumbera/userland-libmemcached/components/libmemcached/build/i86/test/runtests "bin/memcat"
2: Working Directory: /scratch/psumbera/userland-libmemcached/components/libmemcached/build/i86/test
2: Test timeout computed to be: 1500
2: Filters: bin/memcat
2: 
2: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2: runtests is a Catch v2.13.6 host application.
2: Run with -? for options
2: 
2: -------------------------------------------------------------------------------
2: bin/memcat
2:   connection failure
2: -------------------------------------------------------------------------------
2: ./libmemcached-1.1.4/test/tests/bin/memcat.cpp:18
2: ...............................................................................
2:
2: ./libmemcached-1.1.4/test/tests/bin/memcat.cpp:21: FAILED:
2:   REQUIRE_THAT( output, Contains("CONNECTION FAILURE") )
2: with expansion:
2:   "Fatal error for key 'memcat': (fa6a7028) SYSTEM ERROR(Broken pipe),  host:
2:   localhost:13146 -> ./libmemcached-1.1.4/src/libmemcached/io.cc:346
2:   " contains: "CONNECTION FAILURE"
2:
2: ===============================================================================
2: test cases:  1 |  0 passed | 1 failed
2: assertions: 40 | 39 passed | 1 failed
2:
1/1 Test #2: bin/memcat .......................***Failed    5.23 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   5.24 sec

The following tests FAILED:
          2 - bin/memcat (Failed)

Errors while running CTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant