Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ac0e1d3d4af388501796bef80d78876ca1c64d99
Ticket: 2911139fffffffffffffffffffffffffffffffff
http::geturl abuses vwait on async call
User & Date: kakaroto on 2009-12-09 02:33:26
Changes

  1. assignee changed to: "patthoyts"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Hi,
    As discussed on IRC with some of you, aMSN keeps crashing because of "too many nested evaluations", and it seems to be caused by a nested event loop by calling update/vwait/tkwait. I found out what the cause is and it seems to be coming from the http package.
    I'll just copy/paste what I said on IRC, and I'll attach a test tcl file to reproduce the problem :
    
    ==========================================================
    <KaKaRoTo> it basically simulates someone who tries to do 100 geturls asynchronously, and they're all being done from a timer where the geturl gets called after a simple execution stack of maybe 5 functions...
    <KaKaRoTo> with msn I have to do a SOAP (http) request for every contact, so if you have 200 contacts, I'd do 200 geturls.. 
    <KaKaRoTo> I definitely want the geturl to be async! that's why I do -timeout to the geturl, but doing so makes http do a vwait, which causes the above error
    <KaKaRoTo> (ps launch the script with 'wish tst.tcl', if you just do tclsh, it will end because there's no mainloop)
    [...]
    
    <ijchain> <kbk> KaKaRoTo - Don't Do That. Use the -command option to http::geturl so that it doesn't block
    <KaKaRoTo> kbk: I use -command AND -timeout
    <KaKaRoTo> if -timeout is not specified then http will not create the socket with -async
    <KaKaRoTo> I was expecting my -command to get called if a connection error happens, or if the timeout was reached and the http request was not completed
    <KaKaRoTo> I don't understand why -timeout would make it async AND make it vwait... 
    <ijchain> <kbk> Looking at the code --
    <ijchain> <kbk> the only 'vwait' is in 'http_wait':
    <ijchain> <kbk> and the only call to http_wait is gated:
    <ijchain> <kbk>     if {! [info exists state(-command)]} {
    <ijchain> <kbk>  http_wait $token
    <ijchain> <kbk>     }
    <KaKaRoTo> kbk: there's another one
    <KaKaRoTo> there are two calls to 'wait' in the geturl function
    <KaKaRoTo>     # Wait for the connection to complete
    <KaKaRoTo>     if {$state(-timeout) > 0} {
    <KaKaRoTo>  fileevent $s writable [list http::Connect $token]
    <KaKaRoTo>  http::wait $token
    <ijchain> <kbk> ugh - I'm looking at the wrong http.tcl, sec...
    <KaKaRoTo> kbk: np
    <KaKaRoTo> we use http 2.4.4, because we had problems with earlier versions, so people upgrade their system, amsn stops working etc.. so we bundle 2.4.4 and do a package require -exact 2.4.4
    <KaKaRoTo> but I checked the version in CVS and it has the same code
    <ijchain> <kbk> KaKaRoTo - Log a bug. This can't be right.
    ==========================================================
    
    So, as explained, in my opinion, the http::geturl should use -async on the socket if -command is specified, it should also call the callback command in case of a connection error instead of vwait-ing in geturl to return an error.
    
    I hope this gets fixed soon... aMSN is basically completely broken for everyone because of this.
    
    Thanks,
    KaKaRoTo
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "kakaroto"
  10. subsystem changed to: "29. http Package"
  11. title changed to: "http::geturl abuses vwait on async call"
  12. type changed to: "Bug"