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

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

Issue 25511002: Add reusePort argument to ServerSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mac os X version. Created 7 years, 2 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 | « runtime/bin/socket.h ('k') | runtime/bin/socket_linux.cc » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/io_buffer.h" 5 #include "bin/io_buffer.h"
6 #include "bin/socket.h" 6 #include "bin/socket.h"
7 #include "bin/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 296
297 void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) { 297 void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) {
298 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); 298 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0);
299 Dart_Handle host_obj = Dart_GetNativeArgument(args, 1); 299 Dart_Handle host_obj = Dart_GetNativeArgument(args, 1);
300 RawAddr addr; 300 RawAddr addr;
301 Dart_Handle result = GetSockAddr(host_obj, &addr); 301 Dart_Handle result = GetSockAddr(host_obj, &addr);
302 Dart_Handle port_obj = Dart_GetNativeArgument(args, 2); 302 Dart_Handle port_obj = Dart_GetNativeArgument(args, 2);
303 Dart_Handle backlog_obj = Dart_GetNativeArgument(args, 3); 303 Dart_Handle backlog_obj = Dart_GetNativeArgument(args, 3);
304 Dart_Handle v6_only_obj = Dart_GetNativeArgument(args, 4); 304 Dart_Handle v6_only_obj = Dart_GetNativeArgument(args, 4);
305 Dart_Handle reuse_port_obj = Dart_GetNativeArgument(args, 5);
305 bool v6_only = DartUtils::GetBooleanValue(v6_only_obj); 306 bool v6_only = DartUtils::GetBooleanValue(v6_only_obj);
307 bool reuse_port = DartUtils::GetBooleanValue(reuse_port_obj);
306 int64_t port = 0; 308 int64_t port = 0;
307 int64_t backlog = 0; 309 int64_t backlog = 0;
308 if (!Dart_IsError(result) && 310 if (!Dart_IsError(result) &&
309 DartUtils::GetInt64Value(port_obj, &port) && 311 DartUtils::GetInt64Value(port_obj, &port) &&
310 DartUtils::GetInt64Value(backlog_obj, &backlog)) { 312 DartUtils::GetInt64Value(backlog_obj, &backlog)) {
311 intptr_t socket = ServerSocket::CreateBindListen( 313 intptr_t socket = ServerSocket::CreateBindListen(
312 addr, port, backlog, v6_only); 314 addr, port, backlog, v6_only, reuse_port);
313 OSError error; 315 OSError error;
314 Dart_TypedDataReleaseData(host_obj); 316 Dart_TypedDataReleaseData(host_obj);
315 if (socket >= 0) { 317 if (socket >= 0) {
316 Dart_Handle err = Socket::SetSocketIdNativeField(socket_obj, socket); 318 Dart_Handle err = Socket::SetSocketIdNativeField(socket_obj, socket);
317 if (Dart_IsError(err)) Dart_PropagateError(err); 319 if (Dart_IsError(err)) Dart_PropagateError(err);
318 Dart_SetReturnValue(args, Dart_True()); 320 Dart_SetReturnValue(args, Dart_True());
319 } else { 321 } else {
320 if (socket == -5) { 322 if (socket == -5) {
321 OSError os_error(-1, "Invalid host", OSError::kUnknown); 323 OSError os_error(-1, "Invalid host", OSError::kUnknown);
322 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); 324 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); 507 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id);
506 } 508 }
507 509
508 510
509 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { 511 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) {
510 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); 512 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id);
511 } 513 }
512 514
513 } // namespace bin 515 } // namespace bin
514 } // namespace dart 516 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698