Mon Mar 15 16:06:10 EDT 2010 Sending alert email to xxxxxx@mmc.org
can’t read “errMsg”: no such variable
while executing
“set InVal $errMsg”
(”after” script)
To complicate matters, concurrently our network folks are implementing a new SMTP server, so I’m not sure whether the error is due to that or the 5.7 upgrade. Our 5.4 release is pointed to the old email server, while 5.7 is pointed to the new one.
The funny thing is, although the error above is showing in the Netmonitor daemon log, the emails still seem to be successfully sent.
The section of code in tclMail.pkg that seems to be related to the error messages is:
###################################################################
# listn Get data from port
#
# Usage:
# listn
#
# Notes:
# reads data from open Mail Server using established socket
#
# Returns:
# What was read on port
#
###################################################################
proc listn {} {
global InVal
variable SOCK ;# Open Socket
variable DEBUG
set InVal “” ;# Just in case
# Timeout error message
set errMsg “***** Timeout During Read *****”
# Set initial timeout to 10 seconds
# Set subsequent to 1 second
set timeout 10000
set ID [after $timeout {set InVal $errMsg}]
fileevent $SOCK r [list Reader $SOCK]
vwait InVal
catch {after abort}
catch {after cancel $ID}
if {$DEBUG} {
puts “RESPONSE: $InVal”
}
return $InVal
}
The way I’m understanding the code is that the ‘after’ command pushes out the “script” {set InVal $errMsg} to an “event handler” to be executed in 10 seconds. In the meantime, if the fileevent and vwait commands complete within that time, then the “catch {after cancel $ID}” shuts down the execution of the “script” before it happens.
I think what is now happening in 5.7 is that the new email server is timing out for some reason, causing the script to execute the {set InVal $errMsg}, where before it never did. So I’m going to speak to the network folks to see what they can do about that.
But the other issue is this error with the $errMsg variable not being defined. I think this might be a bug in tclMail (at least this version). The man page for the ‘after’ command says that, “The command will be executed at global level (outside the context of any Tcl procedure).” So maybe the script doesn’t error on the variable InVal, because that has been made global at the top of the proc, but it can’t find errMsg because it hasn’t been made global?
Wondering if anyone else has seen this error? Should I try to fix the tclMail package (by inserting “global errMsg”), or is there another revision available that addresses this bug? I’m not that familiar with working with tcl packages, or how to recreate the package index.