On 02-06-2015 23:03, Paolo Bevilacqua wrote:
I just began using Rivet latest version but I cant write reliably to
a
log file.
The file gets corrupted, only pieces of intended output appears in it
at random, as if is where a race condition.
This is my GlobalInitScript:
set log [open /var/www/html/test-dialer-log a+]
fconfigure $log -buffering none -blocking true
And my script, reduced to one line:
puts $log "uri [::rivet::env REQUEST_URI]"
If I use ::rivet::apache_log_error instead of puts, it works
perfectly.
Puzzled. Thanks for any help.
_Always striving to honor my word and commitments_
ciao Paolo
I agree with Harald: Both your problems look to arise from the same
wrong assumption: there is only one Tcl interpreter running within the
web server. The httpd web server runs a variable number of child
processes, each of them owning at least one Tcl interpreter and acting
independently, unless some sort of IPC mechanism is provided. If you
want to log something specific to your application
::rivet::apache_log_error is the canonical way to do it. If you want to
log something interpreter specific you have to give a log file a unique
name (for example by including the process pid in the name, as Harald
suggested)
as to the problem of persistent variables: If you keep the number of
child processes small enough (see the prefork configuration parameters)
you can easily verify that variables *outside the ::request namespace
and other namespaces nested in it* are persistent across subsequest http
requests
try this script, put it in a .rvt file and run it with a browser, then
press F5 repeatedly. You'll se that when the same child process reponds
twice the value of ::persistent_variable is incremented and printed.
Which version of rivet are you running anyway?
<html><head><title>Test persistenza variabili</title></head>
<body>
<pre>
<?
puts -nonewline "\[[pid]\] - "
if {[info exists ::persistent_variable]} {
puts [incr ::persistent_variable]
} else {
puts "::persistent_variable will be created"
set ::persistent_variable 0
}
?>
</pre>
</body></html>
-- Massimo (overcoming the 9 hours jet lag at last)
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscr...@tcl.apache.org
For additional commands, e-mail: rivet-dev-h...@tcl.apache.org