winsock_util.cc 577 B

123456789101112131415161718192021
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "net/base/winsock_util.h"
  5. #include "base/check_op.h"
  6. namespace net {
  7. bool ResetEventIfSignaled(WSAEVENT hEvent) {
  8. DWORD wait_rv = WaitForSingleObject(hEvent, 0);
  9. if (wait_rv == WAIT_TIMEOUT)
  10. return false; // The event object is not signaled.
  11. DCHECK_EQ(wait_rv, static_cast<DWORD>(WAIT_OBJECT_0));
  12. BOOL ok = WSAResetEvent(hEvent);
  13. DCHECK(ok);
  14. return true;
  15. }
  16. } // namespace net