Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch rmax-ipv6-branch Excluding Merge-Ins
This is equivalent to a diff from 188a795873 to 8f2747dc54
2011-06-22
| ||
14:32 | Merge fixes for [socket -async] and other improvements to the unix socket code check-in: 8eefe5a06f user: max tags: trunk, potential incompatibility | |
14:21 | complete a comment in socket.test Closed-Leaf check-in: 8f2747dc54 user: max tags: rmax-ipv6-branch | |
2011-06-16
| ||
15:21 |
| |
2011-05-31
| ||
20:36 | Fix bug 3293874 check-in: 09c2da3a2a user: dgp tags: trunk | |
19:58 | Rewind from a refactoring that veered into the weeds. Closed-Leaf check-in: 1d247886db user: dgp tags: bug-3293874 | |
2011-05-27
| ||
18:36 | Fix [socket -async] for DNS names with more than one address check-in: a1abfd5e94 user: max tags: rmax-ipv6-branch | |
17:50 | fix a timing issue in socket-12.3 check-in: 188a795873 user: max tags: trunk | |
2011-05-25
| ||
14:37 | committed missing tzdata/Africa/Cairo from venkat's last commit check-in: df2425d65c user: kbk tags: trunk | |
Changes to ChangeLog.
|
Changes to doc/socket.n.
︙ | |||
67 68 69 70 71 72 73 | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | + + - - - - - - + + + + + + + + + + + + + + + | port number will be chosen at random by the system software. .TP \fB\-async\fR . This option will cause the client socket to be connected asynchronously. This means that the socket will be created immediately but may not yet be connected to the server, when the call to \fBsocket\fR returns. |
︙ |
Changes to generic/tclIOSock.c.
︙ | |||
174 175 176 177 178 179 180 | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | - - + + + + + | } else if (strcmp(family, "inet6") == 0) { hints.ai_family = AF_INET6; } } } hints.ai_socktype = SOCK_STREAM; |
︙ |
Changes to tests/socket.test.
︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | + + + + + + + + + + + + + + + + + + | # Some tests require the testthread and exec commands testConstraint testthread [llength [info commands testthread]] testConstraint exec [llength [info commands exec]] # Produce a random port number in the Dynamic/Private range # from 49152 through 65535. proc randport {} { expr {int(rand()*16383+49152)} } # Test the latency of tcp connections over the loopback interface. Some OSes # (e.g. NetBSD) seem to use the Nagle algorithm and delayed ACKs, so it takes # up to 200ms for a packet sent to localhost to arrive. We're measuring this # here, so that OSes that don't have this problem can run the tests at full # speed. set server [socket -server {apply {{s a p} {set ::s1 $s}}} 0] set s2 [socket localhost [lindex [fconfigure $server -sockname] 2]] vwait s1; close $server fconfigure $s1 -buffering line fconfigure $s2 -buffering line set t1 [clock milliseconds] puts $s2 test1; gets $s1 puts $s2 test2; gets $s1 close $s1; close $s2 set t2 [clock milliseconds] set latency [expr {($t2-$t1)*2}]; # doubled as a safety margin unset t1 t2 s1 s2 server # If remoteServerIP or remoteServerPort are not set, check in the environment # variables for externally set values. # if {![info exists remoteServerIP]} { if {[info exists env(remoteServerIP)]} { |
︙ | |||
580 581 582 583 584 585 586 | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | - + | vwait x fconfigure $sock -blocking 0 set result a:[gets $sock] lappend result b:[gets $sock] fconfigure $sock -blocking 1 puts $s2 two flush $s2 |
︙ | |||
1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 | 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | # cleanup if {$remoteProcChan ne ""} { catch {sendCommand exit} } catch {close $commandSocket} catch {close $remoteProcChan} } unset ::tcl::unsupported::socketAF test socket-14.0 {[socket -async] when server only listens on one address family} \ -constraints [list socket supported_any] \ -setup { proc accept {s a p} { global x puts $s bye close $s set x ok } set server [socket -server accept -myaddr 127.0.0.1 0] set port [lindex [fconfigure $server -sockname] 2] } -body { set client [socket -async localhost $port] set after [after 1000 {set x [fconfigure $client -error]}] vwait x set x } -cleanup { after cancel $after close $server close $client unset x } -result ok test socket-14.1 {[socket -async] fileevent while still connecting} \ -constraints [list socket supported_any] \ -setup { proc accept {s a p} { global x puts $s bye close $s lappend x ok } set server [socket -server accept -myaddr 127.0.0.1 0] set port [lindex [fconfigure $server -sockname] 2] } -body { set client [socket -async localhost $port] fileevent $client writable { lappend x [expr {[fconfigure $client -error] eq ""}] } set after [after 1000 {set x timeout}] vwait x vwait x set x } -cleanup { after cancel $after close $server close $client unset x } -result {ok 1} test socket-14.2 {[socket -async] fileevent connection refused} \ -constraints [list socket supported_any] \ -body { set client [socket -async localhost [randport]] fileevent $client writable {set x [fconfigure $client -error]} set after [after 1000 {set x timeout}] vwait x if {$x eq "timeout"} { append x ": [fconfigure $client -error]" } set x } -cleanup { after cancel $after close $client unset x } -result "connection refused" ::tcltest::cleanupTests flush stdout return # Local Variables: # mode: tcl # fill-column: 78 # End: |
Changes to unix/tclUnixSock.c.
︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | + + + + | * what they say on the tin. :-) They also only ever refer to their arguments * once, and so can be used without regard to side effects. */ #define SET_BITS(var, bits) ((var) |= (bits)) #define CLEAR_BITS(var, bits) ((var) &= ~(bits)) /* "sock" + a pointer in hex + \0 */ #define SOCK_CHAN_LENGTH 4 + sizeof(void*) * 2 + 1 #define SOCK_TEMPLATE "sock%lx" /* * This is needed to comply with the strict aliasing rules of GCC, but it also * simplifies casting between the different sockaddr types. */ typedef union { struct sockaddr sa; |
︙ | |||
42 43 44 45 46 47 48 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | - + + + + - + - - + + + + + + + + + + + | TcpState *statePtr; int fd; struct TcpFdList *next; } TcpFdList; struct TcpState { Tcl_Channel channel; /* Channel associated with this file. */ |
︙ | |||
85 86 87 88 89 90 91 | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | - - + + - | #define SOCKET_BUFSIZE 4096 /* * Static routines for this file: */ |
︙ | |||
329 330 331 332 333 334 335 | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | - + | TcpState *statePtr = (TcpState *) instanceData; if (mode == TCL_MODE_BLOCKING) { CLEAR_BITS(statePtr->flags, TCP_ASYNC_SOCKET); } else { SET_BITS(statePtr->flags, TCP_ASYNC_SOCKET); } |
︙ | |||
371 372 373 374 375 376 377 | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | - + | if (statePtr->flags & TCP_ASYNC_CONNECT) { if (statePtr->flags & TCP_ASYNC_SOCKET) { timeOut = 0; } else { timeOut = -1; } errno = 0; |
︙ | |||
424 425 426 427 428 429 430 | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | - + | TcpState *statePtr = (TcpState *) instanceData; int bytesRead; *errorCodePtr = 0; if (WaitForConnect(statePtr, errorCodePtr) != 0) { return -1; } |
︙ | |||
474 475 476 477 478 479 480 | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | - + | TcpState *statePtr = (TcpState *) instanceData; int written; *errorCodePtr = 0; if (WaitForConnect(statePtr, errorCodePtr) != 0) { return -1; } |
︙ | |||
518 519 520 521 522 523 524 | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | - + - + + + - + + + + + + + | * Delete a file handler that may be active for this socket if this is a * server socket - the file handler was created automatically by Tcl as * part of the mechanism to accept new client connections. Channel * handlers are already deleted in the generic IO channel closing code * that called this function, so we do not have to delete them here. */ |
︙ | |||
575 576 577 578 579 580 581 | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | - + | default: if (interp) { Tcl_AppendResult(interp, "Socket close2proc called bidirectionally", NULL); } return TCL_ERROR; } |
︙ | |||
628 629 630 631 632 633 634 | 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | + - - - - - + + + + + + + + + - + | } if ((len > 1) && (optionName[1] == 'e') && (strncmp(optionName, "-error", len) == 0)) { socklen_t optlen = sizeof(int); int err, ret; if (statePtr->status == 0) { |
︙ | |||
696 697 698 699 700 701 702 | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | - + | socklen_t size; int found = 0; if (len == 0) { Tcl_DStringAppendElement(dsPtr, "-sockname"); Tcl_DStringStartSublist(dsPtr); } |
︙ | |||
781 782 783 784 785 786 787 | 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | - - - - - - - - - + + + + + + + + + + + - | TcpWatchProc( ClientData instanceData, /* The socket state. */ int mask) /* Events of interest; an OR-ed combination of * TCL_READABLE, TCL_WRITABLE and * TCL_EXCEPTION. */ { TcpState *statePtr = (TcpState *) instanceData; |
︙ | |||
821 822 823 824 825 826 827 | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 | - + + + + + + + + + + + - + - + - + - - + + - + - + - - - - - - - + + - + - - - - - + - - - + + - - - + + + - - - - + + + + - + + + + + + + + + + - - + + - + - + - + - + - + + - + - + + - + - + - - + + - - - + + - - - - - - - + - - - + - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - + + + + + + + + - + + + + - - - + + + - - - + - - - - - - - + + + - - - - - - - - - - - + | TcpGetHandleProc( ClientData instanceData, /* The socket state. */ int direction, /* Not used. */ ClientData *handlePtr) /* Where to store the handle. */ { TcpState *statePtr = (TcpState *) instanceData; |
︙ | |||
1019 1020 1021 1022 1023 1024 1025 | 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 | - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + - - - - + - - - + + + - + - + | const char *host, /* Host on which to open port. */ const char *myaddr, /* Client-side address */ int myport, /* Client-side port */ int async) /* If nonzero, attempt to do an asynchronous * connect. Otherwise we do a blocking * connect. */ { |
︙ | |||
1093 1094 1095 1096 1097 1098 1099 | 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | - + - - - + + - - - + | Tcl_Channel TclpMakeTcpClientChannelMode( ClientData sock, /* The socket to wrap up into a channel. */ int mode) /* ORed combination of TCL_READABLE and * TCL_WRITABLE to indicate file mode. */ { TcpState *statePtr; |
︙ | |||
1145 1146 1147 1148 1149 1150 1151 | 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 | - + | /* Callback for accepting connections from new * clients. */ ClientData acceptProcData) /* Data for the callback. */ { int status = 0, sock = -1, reuseaddr = 1, chosenport = 0; struct addrinfo *addrlist = NULL, *addrPtr; /* socket address */ TcpState *statePtr = NULL; |
︙ | |||
1226 1227 1228 1229 1230 1231 1232 | 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 | - - - + - + + + + | } } status = listen(sock, SOMAXCONN); if (status < 0) { close(sock); continue; } |
︙ | |||
1302 1303 1304 1305 1306 1307 1308 | 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 | - + - + - - - + - - - + | int mask) /* Not used. */ { TcpFdList *fds = data; /* Client data of server socket. */ int newsock; /* The new client socket */ TcpState *newSockState; /* State for new socket. */ address addr; /* The remote address */ socklen_t len; /* For accept interface */ |
︙ |