X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fio%2Fasync%2FAsyncUDPSocket.cpp;h=7f5cd5f9f5951f12cebf57664f141221f319430f;hp=082f7994cb0af8f2ddc0318cb195853d5f04e18a;hb=2a4ad2c8ddc1eb1be8b7ffb607de954ccc2b666e;hpb=fae84c77f3cd88d9e7ccfc39a1fa04ad80f7f540 diff --git a/folly/io/async/AsyncUDPSocket.cpp b/folly/io/async/AsyncUDPSocket.cpp index 082f7994..7f5cd5f9 100644 --- a/folly/io/async/AsyncUDPSocket.cpp +++ b/folly/io/async/AsyncUDPSocket.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ #include -#include #include +#include #include #include #include @@ -36,10 +36,10 @@ namespace folly { AsyncUDPSocket::AsyncUDPSocket(EventBase* evb) : EventHandler(CHECK_NOTNULL(evb)), + readCallback_(nullptr), eventBase_(evb), - fd_(-1), - readCallback_(nullptr) { - DCHECK(evb->isInEventBaseThread()); + fd_(-1) { + evb->dcheckIsInEventBaseThread(); } AsyncUDPSocket::~AsyncUDPSocket() { @@ -176,7 +176,7 @@ ssize_t AsyncUDPSocket::writev(const folly::SocketAddress& address, msg.msg_controllen = 0; msg.msg_flags = 0; - return ::sendmsg(fd_, &msg, 0); + return sendmsg(fd_, &msg, 0); } void AsyncUDPSocket::resumeRead(ReadCallback* cob) { @@ -201,7 +201,7 @@ void AsyncUDPSocket::pauseRead() { } void AsyncUDPSocket::close() { - DCHECK(eventBase_->isInEventBaseThread()); + eventBase_->dcheckIsInEventBaseThread(); if (readCallback_) { auto cob = readCallback_; @@ -248,7 +248,7 @@ void AsyncUDPSocket::handleRead() noexcept { struct sockaddr_storage addrStorage; socklen_t addrLen = sizeof(addrStorage); - memset(&addrStorage, 0, addrLen); + memset(&addrStorage, 0, size_t(addrLen)); struct sockaddr* rawAddr = reinterpret_cast(&addrStorage); rawAddr->sa_family = localAddress_.getFamily(); @@ -260,10 +260,11 @@ void AsyncUDPSocket::handleRead() noexcept { bool truncated = false; if ((size_t)bytesRead > len) { truncated = true; - bytesRead = len; + bytesRead = ssize_t(len); } - readCallback_->onDataAvailable(clientAddress_, bytesRead, truncated); + readCallback_->onDataAvailable( + clientAddress_, size_t(bytesRead), truncated); } } else { if (errno == EAGAIN || errno == EWOULDBLOCK) { @@ -293,7 +294,7 @@ bool AsyncUDPSocket::updateRegistration() noexcept { flags |= READ; } - return registerHandler(flags | PERSIST); + return registerHandler(uint16_t(flags | PERSIST)); } -} // Namespace +} // namespace folly