OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/tcp_socket.h" | 5 #include "net/socket/tcp_socket.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <netinet/tcp.h> | 8 #include <netinet/tcp.h> |
9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
10 | 10 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 int TCPSocketLibevent::TcpFastOpenWrite( | 540 int TCPSocketLibevent::TcpFastOpenWrite( |
541 IOBuffer* buf, | 541 IOBuffer* buf, |
542 int buf_len, | 542 int buf_len, |
543 const CompletionCallback& callback) { | 543 const CompletionCallback& callback) { |
544 SockaddrStorage storage; | 544 SockaddrStorage storage; |
545 int rv = socket_->GetPeerAddress(&storage); | 545 int rv = socket_->GetPeerAddress(&storage); |
546 if (rv != OK) | 546 if (rv != OK) |
547 return rv; | 547 return rv; |
548 | 548 |
549 int flags = 0x20000000; // Magic flag to enable TCP_FASTOPEN. | 549 int flags = 0x20000000; // Magic flag to enable TCP_FASTOPEN. |
550 #if defined(OS_LINUX) | 550 #if defined(OS_LINUX) || defined(OS_ANDROID) |
551 // sendto() will fail with EPIPE when the system doesn't support TCP Fast | 551 // sendto() will fail with EPIPE when the system doesn't support TCP Fast |
552 // Open. Theoretically that shouldn't happen since the caller should check | 552 // Open. Theoretically that shouldn't happen since the caller should check |
553 // for system support on startup, but users may dynamically disable TCP Fast | 553 // for system support on startup, but users may dynamically disable TCP Fast |
554 // Open via sysctl. | 554 // Open via sysctl. |
555 flags |= MSG_NOSIGNAL; | 555 flags |= MSG_NOSIGNAL; |
556 #endif // defined(OS_LINUX) | 556 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
557 rv = HANDLE_EINTR(sendto(socket_->socket_fd(), | 557 rv = HANDLE_EINTR(sendto(socket_->socket_fd(), |
558 buf->data(), | 558 buf->data(), |
559 buf_len, | 559 buf_len, |
560 flags, | 560 flags, |
561 storage.addr, | 561 storage.addr, |
562 storage.addr_len)); | 562 storage.addr_len)); |
563 tcp_fastopen_connected_ = true; | 563 tcp_fastopen_connected_ = true; |
564 | 564 |
565 if (rv >= 0) { | 565 if (rv >= 0) { |
566 fast_open_status_ = FAST_OPEN_FAST_CONNECT_RETURN; | 566 fast_open_status_ = FAST_OPEN_FAST_CONNECT_RETURN; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 617 } |
618 } else { | 618 } else { |
619 fast_open_status_ = (fast_open_status_ == FAST_OPEN_FAST_CONNECT_RETURN ? | 619 fast_open_status_ = (fast_open_status_ == FAST_OPEN_FAST_CONNECT_RETURN ? |
620 FAST_OPEN_SYN_DATA_FAILED : | 620 FAST_OPEN_SYN_DATA_FAILED : |
621 FAST_OPEN_NO_SYN_DATA_FAILED); | 621 FAST_OPEN_NO_SYN_DATA_FAILED); |
622 } | 622 } |
623 } | 623 } |
624 } | 624 } |
625 | 625 |
626 } // namespace net | 626 } // namespace net |
OLD | NEW |