| OLD | NEW |
| 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/eventhandler.h" | 5 #include "bin/eventhandler.h" |
| 6 | 6 |
| 7 #include <process.h> | 7 #include <process.h> |
| 8 #include <winsock2.h> | 8 #include <winsock2.h> |
| 9 #include <ws2tcpip.h> | 9 #include <ws2tcpip.h> |
| 10 #include <mswsock.h> | 10 #include <mswsock.h> |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 void ListenSocket::AcceptComplete(IOBuffer* buffer, HANDLE completion_port) { | 387 void ListenSocket::AcceptComplete(IOBuffer* buffer, HANDLE completion_port) { |
| 388 ScopedLock lock(this); | 388 ScopedLock lock(this); |
| 389 if (!IsClosing()) { | 389 if (!IsClosing()) { |
| 390 // Update the accepted socket to support the full range of API calls. | 390 // Update the accepted socket to support the full range of API calls. |
| 391 SOCKET s = socket(); | 391 SOCKET s = socket(); |
| 392 int rc = setsockopt(buffer->client(), | 392 int rc = setsockopt(buffer->client(), |
| 393 SOL_SOCKET, | 393 SOL_SOCKET, |
| 394 SO_UPDATE_ACCEPT_CONTEXT, | 394 SO_UPDATE_ACCEPT_CONTEXT, |
| 395 reinterpret_cast<char*>(&s), sizeof(s)); | 395 reinterpret_cast<char*>(&s), sizeof(s)); |
| 396 if (rc == NO_ERROR) { | 396 if (rc == NO_ERROR) { |
| 397 linger l; |
| 398 l.l_onoff = 1; |
| 399 l.l_linger = 10; |
| 400 int status = setsockopt(buffer->client(), |
| 401 SOL_SOCKET, |
| 402 SO_LINGER, |
| 403 reinterpret_cast<char*>(&l), |
| 404 sizeof(l)); |
| 405 if (status != NO_ERROR) { |
| 406 FATAL("Failed setting SO_LINGER on socket"); |
| 407 } |
| 397 // Insert the accepted socket into the list. | 408 // Insert the accepted socket into the list. |
| 398 ClientSocket* client_socket = new ClientSocket(buffer->client(), 0); | 409 ClientSocket* client_socket = new ClientSocket(buffer->client(), 0); |
| 399 client_socket->CreateCompletionPort(completion_port); | 410 client_socket->CreateCompletionPort(completion_port); |
| 400 if (accepted_head_ == NULL) { | 411 if (accepted_head_ == NULL) { |
| 401 accepted_head_ = client_socket; | 412 accepted_head_ = client_socket; |
| 402 accepted_tail_ = client_socket; | 413 accepted_tail_ = client_socket; |
| 403 } else { | 414 } else { |
| 404 ASSERT(accepted_tail_ != NULL); | 415 ASSERT(accepted_tail_ != NULL); |
| 405 accepted_tail_->set_next(client_socket); | 416 accepted_tail_->set_next(client_socket); |
| 406 accepted_tail_ = client_socket; | 417 accepted_tail_ = client_socket; |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 reinterpret_cast<uword>(this)); | 897 reinterpret_cast<uword>(this)); |
| 887 if (result != 0) { | 898 if (result != 0) { |
| 888 FATAL1("Failed to start event handler thread %d", result); | 899 FATAL1("Failed to start event handler thread %d", result); |
| 889 } | 900 } |
| 890 | 901 |
| 891 // Initialize Winsock32 | 902 // Initialize Winsock32 |
| 892 if (!Socket::Initialize()) { | 903 if (!Socket::Initialize()) { |
| 893 FATAL("Failed to initialized Windows sockets"); | 904 FATAL("Failed to initialized Windows sockets"); |
| 894 } | 905 } |
| 895 } | 906 } |
| OLD | NEW |