Wapp

Check-in [80f25418a1]
Login

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

Overview
Comment:Serialize the evaluation of the wappInt-handle-request proc. Fix for ticket [207094dd9de1343a]
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 80f25418a1c32b8de4ed8910dddfdabb63ea7ef20363cd24f1d3be15f7f9347d
User & Date: drh 2019-07-30 23:12:27.751
References
2019-07-31
14:30
Fix to [80f25418a1c32b8d] so that it works as CGI again. Also omit a parameter to wappInt-handle-request that is no longer used. (check-in: 44f07d8804 user: drh tags: trunk)
Context
2019-07-31
14:24
If the $argv0 variable is not set, use "/" for SCRIPT_FILENAME and DOCUMENT_ROOT. Ticket [1d0112d75bfbffc8]. (check-in: d52654e48f user: drh tags: trunk)
2019-07-30
23:12
Serialize the evaluation of the wappInt-handle-request proc. Fix for ticket [207094dd9de1343a] (check-in: 80f25418a1 user: drh tags: trunk)
17:47
More details in the explanation of how %-subsitutions work. (check-in: 568d7c208d user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to wapp.tcl.
607
608
609
610
611
612
613
614
615






616


617

















618
619
620
621
622
623
624
    }
  }
}

# Invoke application-supplied methods to generate a reply to
# a single HTTP request.
#
# This routine always runs within [catch], so handle exceptions by
# invoking [error].






#


proc wappInt-handle-request {chan useCgi} {

















  global wapp
  dict set wapp .reply {}
  dict set wapp .mimetype {text/html; charset=utf-8}
  dict set wapp .reply-code {200 Ok}
  dict set wapp .csp {default-src 'self'}

  # Set up additional CGI environment values







|
|
>
>
>
>
>
>

>
>

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







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
    }
  }
}

# Invoke application-supplied methods to generate a reply to
# a single HTTP request.
#
# This routine uses the global variable ::wapp and so must not be nested.
# It must run to completion before the next instance runs.  If a recursive
# instances of this routine starts while another is running, the the
# recursive instance is added to a queue to be invoked after the current
# instance finishes.  Yes, this means that WAPP IS SINGLE THREADED.  Only
# a single page rendering instance my be running at a time.  There can
# be multiple HTTP requests inbound at once, but only one my be processed
# at a time once the request is full read and parsed.
#
set wappIntPending {}
set wappIntLock 0
proc wappInt-handle-request {chan useCgi} {
  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 $useCgi]
    return
  }
  set wappIntLock 1
  catch [list wappInt-handle-request-unsafe $chan $useCgi]
  set wappIntLock 0
  if {[llength $wappIntPending]>0} {
    # If there are deferred requests, then launch the oldest one
    after idle [lindex $wappIntPending 0]
    set wappIntPending [lrange $wappIntPending 1 end]
  }
}
proc wappInt-handle-request-unsafe {chan useCgi} {
  global wapp
  dict set wapp .reply {}
  dict set wapp .mimetype {text/html; charset=utf-8}
  dict set wapp .reply-code {200 Ok}
  dict set wapp .csp {default-src 'self'}

  # Set up additional CGI environment values