Tcl Source Code

Check-in [7a9fe7d77b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:merge trunk
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | novem
Files: files | file ages | folders
SHA1: 7a9fe7d77b6c93fa2e837ab30cb2aea6a35672cf
User & Date: jan.nijtmans 2013-11-13 22:18:33
Context
2013-11-24
22:12
merge trunk check-in: 162f412163 user: jan.nijtmans tags: novem
2013-11-13
22:18
merge trunk check-in: 7a9fe7d77b user: jan.nijtmans tags: novem
2013-11-12
15:47
Grammar check... check-in: 709893c659 user: dkf tags: trunk
2013-11-08
14:38
Merge trunk (order of man.macros inclusion). Simplify TCLAPI definition: Since there are extern "C" ... check-in: 8d35d71882 user: jan.nijtmans tags: novem
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/Tcl.n.

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(see below) unless quoted.
.IP "[2] \fBEvaluation.\fR"
A command is evaluated in two steps.
First, the Tcl interpreter breaks the command into \fIwords\fR
and performs substitutions as described below.
These substitutions are performed in the same way for all
commands.
The first word is used to locate a command procedure to
carry out the command, then all of the words of the command are
passed to the command procedure.
The command procedure is free to interpret each of its words
in any way it likes, such as an integer, variable name, list,
or Tcl script.
Different commands interpret their words differently.
.IP "[3] \fBWords.\fR"







|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(see below) unless quoted.
.IP "[2] \fBEvaluation.\fR"
A command is evaluated in two steps.
First, the Tcl interpreter breaks the command into \fIwords\fR
and performs substitutions as described below.
These substitutions are performed in the same way for all
commands.
Secondly, the first word is used to locate a command procedure to
carry out the command, then all of the words of the command are
passed to the command procedure.
The command procedure is free to interpret each of its words
in any way it likes, such as an integer, variable name, list,
or Tcl script.
Different commands interpret their words differently.
.IP "[3] \fBWords.\fR"

Changes to tests/socket.test.

1837
1838
1839
1840
1841
1842
1843

1844
1845
1846
1847
1848
1849
1850
1851
1852



























1853
1854
1855
1856
1857
1858
1859
            vwait x
        }
        lsort $x
    } -cleanup {
        after cancel $after
        close $client
        close $server

    } -result {{} bye}
test socket-14.5 {[socket -async] which fails before any connect() can be made} \
    -constraints [list socket supported_any] \
    -body {
        # address from rfc5737
        socket -async -myaddr 192.0.2.42 127.0.0.1 [randport]
    } \
    -returnCodes 1 \
    -result {couldn't open socket: cannot assign requested address}



























::tcltest::cleanupTests
flush stdout
return

# Local Variables:
# mode: tcl
# fill-column: 78







>









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
            vwait x
        }
        lsort $x
    } -cleanup {
        after cancel $after
        close $client
        close $server
        unset x
    } -result {{} bye}
test socket-14.5 {[socket -async] which fails before any connect() can be made} \
    -constraints [list socket supported_any] \
    -body {
        # address from rfc5737
        socket -async -myaddr 192.0.2.42 127.0.0.1 [randport]
    } \
    -returnCodes 1 \
    -result {couldn't open socket: cannot assign requested address}
test socket-14.6 {[socket -async] with no event loop and [fconfigure -error] before the socket is connected} \
    -constraints [list socket supported_inet supported_inet6] \
    -setup {
        proc accept {s a p} {
            puts $s bye
            close $s
        }
        set server [socket -server accept -myaddr 127.0.0.1 0]
        set port [lindex [fconfigure $server -sockname] 2]
        set x ""
    } \
    -body {
        set client [socket -async localhost $port]
        foreach _ {1 2} {
            lappend x [lindex [fconfigure $client -sockname] 0]
            lappend x [fconfigure $client -error]
            update
        }
        lappend x [gets $client]
    } \
    -cleanup {
        close $server
        close $client
        unset x
    } \
    -result [list ::1 "connection refused" 127.0.0.1 "" bye]

::tcltest::cleanupTests
flush stdout
return

# Local Variables:
# mode: tcl
# fill-column: 78

Changes to unix/tclUnixSock.c.

733
734
735
736
737
738
739
740



741
742
743
744
745
746
747
    if ((len > 1) && (optionName[1] == 'e') &&
	    (strncmp(optionName, "-error", len) == 0)) {
	socklen_t optlen = sizeof(int);
	int err, ret;

        if (statePtr->status == 0) {
            ret = getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR,
                    (char *) &err, &optlen);



            if (ret < 0) {
                err = errno;
            }
        } else {
            err = statePtr->status;
            statePtr->status = 0;
        }







|
>
>
>







733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
    if ((len > 1) && (optionName[1] == 'e') &&
	    (strncmp(optionName, "-error", len) == 0)) {
	socklen_t optlen = sizeof(int);
	int err, ret;

        if (statePtr->status == 0) {
            ret = getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR,
                            (char *) &err, &optlen);
            if (statePtr->flags & TCP_ASYNC_CONNECT) {
                statePtr->status = err;
            }
            if (ret < 0) {
                err = errno;
            }
        } else {
            err = statePtr->status;
            statePtr->status = 0;
        }
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
                 * Read the error state from the socket to see if the async
                 * connection has succeeded or failed. As this clears the
                 * error condition, we cache the status in the socket state
                 * struct for later retrieval by [fconfigure -error].
                 */

                optlen = sizeof(int);


                getsockopt(state->fds.fd, SOL_SOCKET, SO_ERROR,
                        (char *) &status, &optlen);
                state->status = status;



            }

	    if (status == 0) {
		CLEAR_BITS(state->flags, TCP_ASYNC_CONNECT);
		goto out;
	    }
	}
    }

out:


    if (async_callback) {
        /*
         * An asynchonous connection has finally succeeded or failed.
         */

        TcpWatchProc(state, state->filehandlers);
        TclUnixSetBlockingMode(state->fds.fd, state->cachedBlocking);







>
>
|
|
|
>
>
>
|
>

<







>







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
                 * Read the error state from the socket to see if the async
                 * connection has succeeded or failed. As this clears the
                 * error condition, we cache the status in the socket state
                 * struct for later retrieval by [fconfigure -error].
                 */

                optlen = sizeof(int);

                if (state->status == 0) {
                    getsockopt(state->fds.fd, SOL_SOCKET, SO_ERROR,
                            (char *) &status, &optlen);
                    state->status = status;
                } else {
                    status = state->status;
                    state->status = 0;
                }
            }
	    if (status == 0) {

		goto out;
	    }
	}
    }

out:

    CLEAR_BITS(state->flags, TCP_ASYNC_CONNECT);
    if (async_callback) {
        /*
         * An asynchonous connection has finally succeeded or failed.
         */

        TcpWatchProc(state, state->filehandlers);
        TclUnixSetBlockingMode(state->fds.fd, state->cachedBlocking);