Skip to content
Tcl Source Code History Of Ticket 3472316fffffffffffffffffffffffffffffffff
Login

History Of Ticket 3472316fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 3472316fffffffffffffffffffffffffffffffff

  1. Ticket change [3968ceb651] (rid 112384) by zwischenzugs on 2012-01-11 09:32:04:

    1. assignee initialized to: "patthoyts"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      It appears that if you call fconfigure twice on a reset socket (for example) a call to fconfigure <sock> -error can only be called once to retrieve the error.
      
      [Terminal 1]
      T1 $ tclsh
      % socket -server sockproc 12345
      sock5
      % 
      
      [Terminal 2]
      T2 $ tclsh
      % socket localhost 12345
      sock5
      % 
      
      [Terminal 1]
      % ^C
      T1 $
      
      [Terminal 2]
      % fconfigure sock5 -error
      connection reset by peer
      % fconfigure sock5 -error
      % 
      
      It seems this causes this if clause to ultimately return an error string which means it's not possible to determine whether the writeable socket has eof and/or threw an error:
      
          if {
          [eof $state(sock)] ||
          [string length [fconfigure $state(sock) -error]]
          } then {
          Finish $token "connect failed [fconfigure $state(sock) -error]" 1
          } else {
      
      tcl8.5.11/library/http/http.tcl
      
      As an aside, the documentation for socket appears not to state that the error message can only be retrieved once.
      
      If the fconfigure <sock> -error is run twice in quick succession this appears to make no difference (ie I couldn't determine that it was a race condition with sockets still in the OS's memory).
      
    4. foundin initialized to: "obsolete: 8.5.11"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "zwischenzugs"
    10. subsystem initialized to: "29. http Package"
    11. title initialized to: "fconfigure <sock> -error called twice in Connect"
    12. type initialized to: "Bug"
  2. Ticket change [f0a1e4390b] (rid 109224) by zwischenzugs on 2012-01-11 16:37:25:

    1. icomment:
      NB socket documentation states:
      
      CONFIGURATION OPTIONS
             The fconfigure command can be used to query several readonly configuration options for socket channels:
      
             -error This option gets the current error status of the given socket.  This is useful when you need to determine if an asynchronous connect operation succeeded.  If there was an error, the  error  message  is  returned.   If
                    there was no error, an empty string is returned.
      
      
      
    2. login: "zwischenzugs"
    3. mimetype: "text/plain"
    4. priority changed to: "8"
    5. username: "zwischenzugs"
  3. Ticket change [2381688438] (rid 130950) by ferrieux on 2012-01-11 22:04:07:

    1. icomment:
      It is a documentation bug indeed: the (read-side) -error option is in 1-to-1 mapping with the getsockopt(SO_ERROR) call, which on all platforms I know of is documented as "getting *and* clearing the error status".
      So it's not a race condition, it is as documented on the OS side, only Tcl docs failsto propagate the info.
      
      Will fix the doc soon ; fix of the http package is left in its maintainer's hands.
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  4. Ticket change [b48f739210] (rid 125062) by ferrieux on 2012-01-13 04:02:46:

    1. icomment:
      Doc fixed in both 8.[56] branches. 
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  5. Ticket change [83f2796138] (rid 117462) by patthoyts on 2012-01-13 04:34:42:

    1. icomment:
      I'm not really sure why this didn't just get rolled into the documentation fix. Someone with more familiarity with fossil can apply this:
      Index: library/http/http.tcl
      ===================================================================
      --- library/http/http.tcl
      +++ library/http/http.tcl
      @@ -864,13 +864,13 @@
           variable $token
           upvar 0 $token state
           global errorInfo errorCode
           if {
              [eof $state(sock)] ||
      -       [string length [fconfigure $state(sock) -error]]
      +       [string length [set sockerr [fconfigure $state(sock) -error]]]
           } then {
      -       Finish $token "connect failed [fconfigure $state(sock) -error]" 1
      +       Finish $token "connect failed $sockerr" 1
           } else {
              set state(status) connect
              fileevent $state(sock) writable {}
           }
           return
      
      
    2. login: "patthoyts"
    3. mimetype: "text/plain"
    4. username: "patthoyts"
  6. Ticket change [4d96633f2d] (rid 127080) by zwischenzugs on 2012-01-13 15:54:06:

    1. icomment:
      Won't that fail if there's an eof on the socket?
      
      imiell@alruccabah:~$ tclsh
      % if {1 || [set a 1]} {
      puts $a
      }
      can't read "a": no such variable
      % 
      
      
      
    2. login: "zwischenzugs"
    3. mimetype: "text/plain"
    4. username: "zwischenzugs"
  7. Ticket change [2e4c21d45f] (rid 119201) by dkf on 2012-01-13 18:53:39:

    1. icomment:
      I think that can't happen; eof only happens after a read or write fails, and none has occurred at that point. (Well, maybe; don't know how TLS affects this.)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  8. Ticket change [8a91c98842] (rid 127413) by nijtmans on 2012-03-27 16:29:43:

    1. closedate changed to: "2012-03-27T09:29:43"
    2. closer changed to: "nijtmans"
    3. icomment:
      
      
      allow_comments - 1
      
      This is already fixed by dkf (2012-01-13)
      in all branches, so can be closed.
      
      
    4. login: "nijtmans"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "nijtmans"