Wapp

wappInt-handle-request bug?
Login

wappInt-handle-request bug?

(1) By Oleg (oleg4tcltk) on 2020-06-05 14:19:47

Hi.

The wappInt-handle-request proc is called with wapp set outside(by its caller). And in some situations, when we have deffered requests, we can got the wrong wapp variable content in the request handler. I.e(my comments is in upper case):

```
proc wappInt-handle-request {chan} {
  # HERE WE HAVE wapp SET WITH OUR CONNECTION DATA
  global wappIntPending wappIntLock
  fileevent $chan readable {}
  if {$wappIntLock} {
    # Another instance of request is already running, so defer this one
    lappend wappIntPending [list wappInt-handle-request $chan]
    return
  }
  set wappIntLock 1
  catch [list wappInt-handle-request-unsafe $chan]
  set wappIntLock 0
  if {[llength $wappIntPending]>0} {
    # If there are deferred requests, then launch the oldest one
    # HERE WE CALL ANOTHER REQUEST, AND WHAT wapp CONTAINS FOR IT?
    after idle [lindex $wappIntPending 0]
    set wappIntPending [lrange $wappIntPending 1 end]
  }
}
```