Replace racy half-open increment-if-zero with a compare-and-swap

The current code is racy:

    if cb.halfOpens == 0 {
      atomic.AddInt64(&cb.halfOpens, 1)
      return halfopen
    }

This commit replaces the increment-if-zero with a compare-and-swap-if-zero, ensuring that only one thread will return `halfopen`, which seems to be the intent of the current code.