Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: src/platform-win32.cc

Issue 10412021: Make socket send and receive more robust and return 0 on failure. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/debug-agent.cc ('K') | « src/platform-posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 int status = shutdown(socket_, SD_BOTH); 1841 int status = shutdown(socket_, SD_BOTH);
1842 closesocket(socket_); 1842 closesocket(socket_);
1843 socket_ = INVALID_SOCKET; 1843 socket_ = INVALID_SOCKET;
1844 return status == SOCKET_ERROR; 1844 return status == SOCKET_ERROR;
1845 } 1845 }
1846 return true; 1846 return true;
1847 } 1847 }
1848 1848
1849 1849
1850 int Win32Socket::Send(const char* data, int len) const { 1850 int Win32Socket::Send(const char* data, int len) const {
1851 if (len <= 0) return 0;
1851 int status = send(socket_, data, len, 0); 1852 int status = send(socket_, data, len, 0);
1852 return status; 1853 return (status == SOCKET_ERROR) ? 0 : status;
1853 } 1854 }
1854 1855
1855 1856
1856 int Win32Socket::Receive(char* data, int len) const { 1857 int Win32Socket::Receive(char* data, int len) const {
1858 if (len <= 0) return 0;
1857 int status = recv(socket_, data, len, 0); 1859 int status = recv(socket_, data, len, 0);
1858 return status; 1860 return (status == SOCKET_ERROR) ? 0 : status;
1859 } 1861 }
1860 1862
1861 1863
1862 bool Win32Socket::SetReuseAddress(bool reuse_address) { 1864 bool Win32Socket::SetReuseAddress(bool reuse_address) {
1863 BOOL on = reuse_address ? true : false; 1865 BOOL on = reuse_address ? true : false;
1864 int status = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, 1866 int status = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
1865 reinterpret_cast<char*>(&on), sizeof(on)); 1867 reinterpret_cast<char*>(&on), sizeof(on));
1866 return status == SOCKET_ERROR; 1868 return status == SOCKET_ERROR;
1867 } 1869 }
1868 1870
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 2107
2106 2108
2107 void Sampler::Stop() { 2109 void Sampler::Stop() {
2108 ASSERT(IsActive()); 2110 ASSERT(IsActive());
2109 SamplerThread::RemoveActiveSampler(this); 2111 SamplerThread::RemoveActiveSampler(this);
2110 SetActive(false); 2112 SetActive(false);
2111 } 2113 }
2112 2114
2113 2115
2114 } } // namespace v8::internal 2116 } } // namespace v8::internal
OLDNEW
« src/debug-agent.cc ('K') | « src/platform-posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698