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: |
da179330edce07c354f610f66de0c1e8 |
User & Date: | jan.nijtmans 2013-01-23 14:11:12 |
Context
2013-01-24
| ||
10:37 | Convert Tcl_GetIndexFromObj implementation to macro check-in: 039696e2d8 user: jan.nijtmans tags: novem | |
2013-01-23
| ||
14:11 | merge trunk check-in: da179330ed user: jan.nijtmans tags: novem | |
14:04 | Fix [2911139]: connect asynchronously, but without unnecessary internal waits. check-in: b242bb3e4b user: jan.nijtmans tags: trunk | |
2013-01-21
| ||
13:52 | merge-mark check-in: 73eaab6e6c user: jan.nijtmans tags: novem | |
Changes
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2013-01-18 Jan Nijtmans <[email protected]> * generic/tclPort.h: [Bug 3598300]: unix: tcl.h does not include sys/stat.h 2013-01-17 Donal K. Fellows <[email protected]> | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 2013-01-23 Donal K. Fellows <[email protected]> * library/http/http.tcl (http::geturl): [Bug 2911139]: Do not do vwait for connect to avoid reentrancy problems (except when operating without a -command option). Internally, this means that all sockets created by the http package will always be operated in asynchronous mode. 2013-01-18 Jan Nijtmans <[email protected]> * generic/tclPort.h: [Bug 3598300]: unix: tcl.h does not include sys/stat.h 2013-01-17 Donal K. Fellows <[email protected]> |
︙ | ︙ |
Changes to library/http/http.tcl.
︙ | ︙ | |||
533 534 535 536 537 538 539 | append url $srvurl # Don't append the fragment! set state(url) $url # If a timeout is specified we set up the after event and arrange for an # asynchronous socket connection. | | < | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | append url $srvurl # Don't append the fragment! set state(url) $url # If a timeout is specified we set up the after event and arrange for an # asynchronous socket connection. set sockopts [list -async] if {$state(-timeout) > 0} { set state(after) [after $state(-timeout) \ [list http::reset $token timeout]] } # If we are using the proxy, we must pass in the full URL that includes # the server name. if {[info exists phost] && ($phost ne "")} { set srvurl $url |
︙ | ︙ | |||
593 594 595 596 597 598 599 | set state(sock) $sock Log "Using $sock for $state(socketinfo)" \ [expr {$state(-keepalive)?"keepalive":""}] if {$state(-keepalive)} { set socketmap($state(socketinfo)) $sock } | | > | < | > > > > > > > | < | | | | > > > > > > > > > > > > > > > | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | set state(sock) $sock Log "Using $sock for $state(socketinfo)" \ [expr {$state(-keepalive)?"keepalive":""}] if {$state(-keepalive)} { set socketmap($state(socketinfo)) $sock } if {![info exists phost]} { set phost "" } fileevent $sock writable [list http::Connect $token $proto $phost $srvurl] # Wait for the connection to complete. if {![info exists state(-command)]} { # geturl does EVERYTHING asynchronously, so if the user # calls it synchronously, we just do a wait here. http::wait $token if {![info exists state]} { # If we timed out then Finish has been called and the users # command callback may have cleaned up the token. If so we end up # here with nothing left to do. return $token } elseif {$state(status) eq "error"} { # Something went wrong while trying to establish the connection. # Clean up after events and such, but DON'T call the command # callback (if available) because we're going to throw an # exception from here instead. set err [lindex $state(error) 0] cleanup $token return -code error $err } } return $token } proc http::Connected { token proto phost srvurl} { variable http variable urlTypes variable $token upvar 0 $token state # Set back the variables needed here set sock $state(sock) set isQueryChannel [info exists state(-querychannel)] set isQuery [info exists state(-query)] set host [lindex [split $state(socketinfo) :] 0] set port [lindex [split $state(socketinfo) :] 1] set defport [lindex $urlTypes($proto) 0] # Send data in cr-lf format, but accept any line terminators fconfigure $sock -translation {auto crlf} -buffersize $state(-blocksize) # The following is disallowed in safe interpreters, but the socket is # already in non-blocking mode in that case. |
︙ | ︙ | |||
749 750 751 752 753 754 755 | fileevent $sock writable [list http::Write $token] } else { puts $sock "" flush $sock fileevent $sock readable [list http::Event $sock $token] } | < < < < < < < < < < < < < < < | < < < | 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | fileevent $sock writable [list http::Write $token] } else { puts $sock "" flush $sock fileevent $sock readable [list http::Event $sock $token] } } err]} { # The socket probably was never connected, or the connection dropped # later. # if state(status) is error, it means someone's already called Finish # to do the above-described clean up. if {$state(status) ne "error"} { Finish $token $err } } } # Data access functions: # Data - the URL data # Status - the transaction status: ok, reset, eof, timeout # Code - the HTTP transaction code, e.g., 200 # Size - the size of the URL data |
︙ | ︙ | |||
861 862 863 864 865 866 867 | # Arguments # token The token returned from http::geturl # # Side Effects # Sets the status of the connection, which unblocks # the waiting geturl call | | | < > | 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 | # Arguments # token The token returned from http::geturl # # Side Effects # Sets the status of the connection, which unblocks # the waiting geturl call proc http::Connect {token proto phost srvurl} { variable $token upvar 0 $token state set err "due to unexpected EOF" if { [eof $state(sock)] || [set err [fconfigure $state(sock) -error]] ne "" } { Finish $token "connect failed $err" } else { fileevent $state(sock) writable {} ::http::Connected $token $proto $phost $srvurl } return } # http::Write # # Write POST query data to the socket |
︙ | ︙ |
Changes to tests/http.test.
︙ | ︙ | |||
543 544 545 546 547 548 549 | # connection "completes" but the socket is bad. test http-4.14 {http::Event} -body { set token [http::geturl $badurl/?timeout=10 -timeout 10000 -command \#] if {$token eq ""} { error "bogus return from http::geturl" } http::wait $token | | < | | | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | # connection "completes" but the socket is bad. test http-4.14 {http::Event} -body { set token [http::geturl $badurl/?timeout=10 -timeout 10000 -command \#] if {$token eq ""} { error "bogus return from http::geturl" } http::wait $token lindex [http::error $token] 0 } -cleanup { catch {http::cleanup $token} } -result {connect failed connection refused} # Bogus host test http-4.15 {http::Event} -body { # This test may fail if you use a proxy server. That is to be # expected and is not a problem with Tcl. set token [http::geturl //not_a_host.tcl.tk -timeout 1000 -command \#] http::wait $token http::status $token |
︙ | ︙ |
Changes to unix/tclUnixCompat.c.
︙ | ︙ | |||
994 995 996 997 998 999 1000 | /* See: <http://en.wikipedia.org/wiki/CPUID> */ #if defined(HAVE_CPUID) __asm__ __volatile__("mov %%ebx, %%edi \n\t" /* save %ebx */ "cpuid \n\t" "mov %%ebx, %%esi \n\t" /* save what cpuid just put in %ebx */ "mov %%edi, %%ebx \n\t" /* restore the old %ebx */ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3]) | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | /* See: <http://en.wikipedia.org/wiki/CPUID> */ #if defined(HAVE_CPUID) __asm__ __volatile__("mov %%ebx, %%edi \n\t" /* save %ebx */ "cpuid \n\t" "mov %%ebx, %%esi \n\t" /* save what cpuid just put in %ebx */ "mov %%edi, %%ebx \n\t" /* restore the old %ebx */ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3]) : "a"(index) : "edi","ebx"); status = TCL_OK; #endif return status; } /* * Local Variables: |
︙ | ︙ |