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

Side by Side Diff: runtime/bin/socket_win.cc

Issue 10905063: Don't use TEMP_FAILURE_RETRY on windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename s_addr to socket_addr. Created 8 years, 3 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
« no previous file with comments | « no previous file | 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "bin/eventhandler.h" 6 #include "bin/eventhandler.h"
7 #include "bin/socket.h" 7 #include "bin/socket.h"
8 8
9 bool Socket::Initialize() { 9 bool Socket::Initialize() {
10 int err; 10 int err;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 free(buffer); 204 free(buffer);
205 return NULL; 205 return NULL;
206 } 206 }
207 return buffer; 207 return buffer;
208 } 208 }
209 209
210 210
211 intptr_t ServerSocket::CreateBindListen(const char* host, 211 intptr_t ServerSocket::CreateBindListen(const char* host,
212 intptr_t port, 212 intptr_t port,
213 intptr_t backlog) { 213 intptr_t backlog) {
214 unsigned long s_addr = TEMP_FAILURE_RETRY(inet_addr(host)); // NOLINT 214 unsigned long socket_addr = inet_addr(host); // NOLINT
215 if (s_addr == INADDR_NONE) { 215 if (socket_addr == INADDR_NONE) {
216 return -5; 216 return -5;
217 } 217 }
218 218
219 SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 219 SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
220 if (s == INVALID_SOCKET) { 220 if (s == INVALID_SOCKET) {
221 return -1; 221 return -1;
222 } 222 }
223 223
224 BOOL optval = true; 224 BOOL optval = true;
225 int status = setsockopt(s, 225 int status = setsockopt(s,
226 SOL_SOCKET, 226 SOL_SOCKET,
227 SO_REUSEADDR, 227 SO_REUSEADDR,
228 reinterpret_cast<const char*>(&optval), 228 reinterpret_cast<const char*>(&optval),
229 sizeof(optval)); 229 sizeof(optval));
230 if (status == SOCKET_ERROR) { 230 if (status == SOCKET_ERROR) {
231 DWORD rc = WSAGetLastError(); 231 DWORD rc = WSAGetLastError();
232 closesocket(s); 232 closesocket(s);
233 SetLastError(rc); 233 SetLastError(rc);
234 return -1; 234 return -1;
235 } 235 }
236 236
237 sockaddr_in addr; 237 sockaddr_in addr;
238 memset(&addr, 0, sizeof(addr)); 238 memset(&addr, 0, sizeof(addr));
239 addr.sin_family = AF_INET; 239 addr.sin_family = AF_INET;
240 addr.sin_addr.s_addr = s_addr; 240 addr.sin_addr.s_addr = socket_addr;
241 addr.sin_port = htons(port); 241 addr.sin_port = htons(port);
242 status = bind(s, 242 status = bind(s,
243 reinterpret_cast<struct sockaddr *>(&addr), 243 reinterpret_cast<struct sockaddr *>(&addr),
244 sizeof(addr)); 244 sizeof(addr));
245 if (status == SOCKET_ERROR) { 245 if (status == SOCKET_ERROR) {
246 DWORD rc = WSAGetLastError(); 246 DWORD rc = WSAGetLastError();
247 closesocket(s); 247 closesocket(s);
248 SetLastError(rc); 248 SetLastError(rc);
249 return -1; 249 return -1;
250 } 250 }
251 251
252 status = listen(s, backlog); 252 status = listen(s, backlog);
253 if (status == SOCKET_ERROR) { 253 if (status == SOCKET_ERROR) {
254 DWORD rc = WSAGetLastError(); 254 DWORD rc = WSAGetLastError();
255 closesocket(s); 255 closesocket(s);
256 SetLastError(rc); 256 SetLastError(rc);
257 return -1; 257 return -1;
258 } 258 }
259 259
260 ListenSocket* listen_socket = new ListenSocket(s); 260 ListenSocket* listen_socket = new ListenSocket(s);
261 return reinterpret_cast<intptr_t>(listen_socket); 261 return reinterpret_cast<intptr_t>(listen_socket);
262 } 262 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698