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

Side by Side Diff: runtime/bin/socket_patch.dart

Issue 2632543002: Don't clobber SocketError's OSError on failed write and send. (Closed)
Patch Set: Really fix it Created 3 years, 11 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
« 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) 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 @patch class RawServerSocket { 5 @patch class RawServerSocket {
6 @patch static Future<RawServerSocket> bind(address, 6 @patch static Future<RawServerSocket> bind(address,
7 int port, 7 int port,
8 {int backlog: 0, 8 {int backlog: 0,
9 bool v6Only: false, 9 bool v6Only: false,
10 bool shared: false}) { 10 bool shared: false}) {
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if (offset is! int || bytes is! int) { 662 if (offset is! int || bytes is! int) {
663 throw new ArgumentError("Invalid arguments to write on Socket"); 663 throw new ArgumentError("Invalid arguments to write on Socket");
664 } 664 }
665 if (isClosing || isClosed) return 0; 665 if (isClosing || isClosed) return 0;
666 if (bytes == 0) return 0; 666 if (bytes == 0) return 0;
667 _BufferAndStart bufferAndStart = 667 _BufferAndStart bufferAndStart =
668 _ensureFastAndSerializableByteData(buffer, offset, offset + bytes); 668 _ensureFastAndSerializableByteData(buffer, offset, offset + bytes);
669 var result = 669 var result =
670 nativeWrite(bufferAndStart.buffer, bufferAndStart.start, bytes); 670 nativeWrite(bufferAndStart.buffer, bufferAndStart.start, bytes);
671 if (result is OSError) { 671 if (result is OSError) {
672 scheduleMicrotask(() => reportError(result, "Write failed")); 672 OSError osError = result;
673 scheduleMicrotask(() => reportError(osError, "Write failed"));
673 result = 0; 674 result = 0;
674 } 675 }
675 // The result may be negative, if we forced a short write for testing 676 // The result may be negative, if we forced a short write for testing
676 // purpose. In such case, don't mark writeAvailable as false, as we don't 677 // purpose. In such case, don't mark writeAvailable as false, as we don't
677 // know if we'll receive an event. It's better to just retry. 678 // know if we'll receive an event. It's better to just retry.
678 if (result >= 0 && result < bytes) { 679 if (result >= 0 && result < bytes) {
679 writeAvailable = false; 680 writeAvailable = false;
680 } 681 }
681 // Negate the result, as stated above. 682 // Negate the result, as stated above.
682 if (result < 0) result = -result; 683 if (result < 0) result = -result;
683 // TODO(ricow): Remove when we track internal and pipe uses. 684 // TODO(ricow): Remove when we track internal and pipe uses.
684 assert(resourceInfo != null || isPipe || isInternal); 685 assert(resourceInfo != null || isPipe || isInternal);
685 if (resourceInfo != null) { 686 if (resourceInfo != null) {
686 resourceInfo.addWrite(result); 687 resourceInfo.addWrite(result);
687 } 688 }
688 return result; 689 return result;
689 } 690 }
690 691
691 int send(List<int> buffer, int offset, int bytes, 692 int send(List<int> buffer, int offset, int bytes,
692 InternetAddress address, int port) { 693 InternetAddress address, int port) {
693 _throwOnBadPort(port); 694 _throwOnBadPort(port);
694 if (isClosing || isClosed) return 0; 695 if (isClosing || isClosed) return 0;
695 _BufferAndStart bufferAndStart = 696 _BufferAndStart bufferAndStart =
696 _ensureFastAndSerializableByteData( 697 _ensureFastAndSerializableByteData(
697 buffer, offset, bytes); 698 buffer, offset, bytes);
698 var result = nativeSendTo( 699 var result = nativeSendTo(
699 bufferAndStart.buffer, bufferAndStart.start, bytes, 700 bufferAndStart.buffer, bufferAndStart.start, bytes,
700 address._in_addr, port); 701 address._in_addr, port);
701 if (result is OSError) { 702 if (result is OSError) {
702 scheduleMicrotask(() => reportError(result, "Send failed")); 703 OSError osError = result;
704 scheduleMicrotask(() => reportError(osError, "Send failed"));
703 result = 0; 705 result = 0;
704 } 706 }
705 // TODO(ricow): Remove when we track internal and pipe uses. 707 // TODO(ricow): Remove when we track internal and pipe uses.
706 assert(resourceInfo != null || isPipe || isInternal); 708 assert(resourceInfo != null || isPipe || isInternal);
707 if (resourceInfo != null) { 709 if (resourceInfo != null) {
708 resourceInfo.addWrite(result); 710 resourceInfo.addWrite(result);
709 } 711 }
710 return result; 712 return result;
711 } 713 }
712 714
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 Datagram _makeDatagram(List<int> data, 1879 Datagram _makeDatagram(List<int> data,
1878 String address, 1880 String address,
1879 List<int> in_addr, 1881 List<int> in_addr,
1880 int port) { 1882 int port) {
1881 return new Datagram( 1883 return new Datagram(
1882 data, 1884 data,
1883 new _InternetAddress(address, null, in_addr), 1885 new _InternetAddress(address, null, in_addr),
1884 port); 1886 port);
1885 } 1887 }
1886 1888
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