From d6176b0dcacb124539e0cfd051e6d93a9782f020 Mon Sep 17 00:00:00 2001 From: "rmistry@google.com" Date: Thu, 23 Aug 2012 18:14:13 +0000 Subject: Result of running tools/sanitize_source_files.py (which was added in https://codereview.appspot.com/6465078/) This CL is part II of IV (I broke down the 1280 files into 4 CLs). Review URL: https://codereview.appspot.com/6474054 git-svn-id: http://skia.googlecode.com/svn/trunk@5263 2bbb7eff-a529-9590-31e7-b0007b416f81 --- experimental/Networking/SkSockets.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'experimental/Networking/SkSockets.cpp') diff --git a/experimental/Networking/SkSockets.cpp b/experimental/Networking/SkSockets.cpp index 7b7d6fcff7..db9da09d4d 100644 --- a/experimental/Networking/SkSockets.cpp +++ b/experimental/Networking/SkSockets.cpp @@ -33,7 +33,7 @@ int SkSocket::createSocket() { return -1; } int reuse = 1; - + if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(int)) < 0) { SkDebugf("error: %s\n", strerror(errno)); return -1; @@ -49,10 +49,10 @@ int SkSocket::createSocket() { void SkSocket::closeSocket(int sockfd) { if (!fReady) return; - + close(sockfd); //SkDebugf("Closed fd:%d\n", sockfd); - + if (FD_ISSET(sockfd, &fMasterSet)) { FD_CLR(sockfd, &fMasterSet); if (sockfd >= fMaxfd) { @@ -60,7 +60,7 @@ void SkSocket::closeSocket(int sockfd) { fMaxfd -= 1; } } - if (0 == fMaxfd) + if (0 == fMaxfd) fConnected = false; } @@ -70,7 +70,7 @@ void SkSocket::onFailedConnection(int sockfd) { void SkSocket::setNonBlocking(int sockfd) { int flags = fcntl(sockfd, F_GETFL); - fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); + fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); } void SkSocket::addToMasterSet(int sockfd) { @@ -79,9 +79,9 @@ void SkSocket::addToMasterSet(int sockfd) { fMaxfd = sockfd; } -int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType, +int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType, void*), void* context) { - if (!fConnected || !fReady || NULL == onRead || NULL == context + if (!fConnected || !fReady || NULL == onRead || NULL == context || fReadSuspended) return -1; @@ -91,7 +91,7 @@ int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType, for (int i = 0; i <= fMaxfd; ++i) { if (!FD_ISSET (i, &fMasterSet)) continue; - + memset(packet, 0, PACKET_SIZE); SkDynamicMemoryWStream stream; int attempts = 0; @@ -155,13 +155,13 @@ int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType, this->onFailedConnection(i); continue; } - + if (bytesReadInTransfer > 0) { SkData* data = stream.copyToData(); SkASSERT(data->size() == bytesReadInTransfer); onRead(i, data->data(), data->size(), h.type, context); data->unref(); - + totalBytesRead += bytesReadInTransfer; } } @@ -312,7 +312,7 @@ int SkTCPServer::disconnectAll() { SkTCPClient::SkTCPClient(const char* hostname, int port) { //Add fSockfd since the client will be using it to read/write this->addToMasterSet(fSockfd); - + hostent* server = gethostbyname(hostname); if (server) { fServerAddr.sin_family = AF_INET; -- cgit v1.2.3