Commit 339ba117 authored by Per Cederqvist's avatar Per Cederqvist

Log when the test suite lock is obtained and released.

* src/server/testsuite/locksuite.py (now): New function.
(main): Include a timestamp in the "locked" and "bye" messages.
* src/server/testsuite/config/unix.exp (obtain_lock): Log when the
lock is obtained.  Log a warning if the expect statement should be
exited for unexpected reasons.
(release_lock): Log when the lock is released.

Fix a minor memory leak.
* src/server/conf-file.c (read_config): Fix a memory leak when the
config file was not found.
parent 1ae97fc1
2006-02-02 Per Cederqvist <ceder@lysator.liu.se>
Log when the test suite lock is obtained and released.
* src/server/testsuite/locksuite.py (now): New function.
(main): Include a timestamp in the "locked" and "bye" messages.
* src/server/testsuite/config/unix.exp (obtain_lock): Log when the
lock is obtained. Log a warning if the expect statement should be
exited for unexpected reasons.
(release_lock): Log when the lock is released.
Fix a minor memory leak.
* src/server/conf-file.c (read_config): Fix a memory leak when the
config file was not found.
Compilation error fix.
* src/server/server-config.c (dump_cfg_timevals): Updated to the
changes in struct datatype introduced yesterday.
......
......@@ -225,7 +225,12 @@ read_config(const char *config_file,
fp = i_fopen(config_file, "r");
if (fp == NULL)
{
free_config(par);
sfree(assignment_count);
assignment_count = 0;
restart_kom("cannot open config file %s\n", config_file);
}
while (configure_line(fp, par, &errs) != EOF)
;
......
......@@ -113,12 +113,15 @@ proc obtain_lock {} {
global any
global srcdir
global python
global test
if {$lock_count == 0} {
set redo 1
while {$redo} {
spawn $python $srcdir/locksuite.py
set lock_id $spawn_id
set exit_warn 1
set test "obtaining test suite lock"
expect {
-re "^locking...$nl" {
exp_continue
......@@ -139,19 +142,27 @@ proc obtain_lock {} {
expect bye
expect eof
wait
set exit_warn 0
}
-re "^locked$nl" {
-re "^locked (.*)$nl" {
pass "$test at $expect_out(1,string)"
set redo 0
set exit_warn 0
}
timeout {
exp_continue
}
eof {
fail "obtaining lock failed"
fail "$test"
wait
set redo 0
set exit_warn 0
}
}
if {$exit_warn == 1} {
warning "$test: unexpected exit from expect statement" 0
}
unset test
}
}
set lock_count [expr {$lock_count + 1}]
......@@ -162,17 +173,22 @@ proc release_lock {} {
global nl
global spawn_id
global lock_id
global test
if {$lock_count == 1} {
set spawn_id $lock_id
send "exit\n"
set test "releasing test suite lock"
expect {
-re "queued: socket (.*)$nl" {
warning "Test suite blocked for $expect_out(1,string)" 0
exp_continue
}
-re "bye$nl"
-re "bye (.*)$nl" {
pass "$test at $expect_out(1,string)"
}
}
unset test
expect eof
wait
}
......
......@@ -62,14 +62,19 @@
# will print this message and stop trying to obtain the lock. If
# this happens, the process should send the "exit\n" command.
#
# "locked\n": the lock has been successfully obtained.
# "locked $TIMESTAMP\n": the lock has been successfully obtained. The
# timestamp is on the "YYYY-MM-DD HH:MM:SS.ssssss" format and can
# be used for diagnostic purposes.
#
# "queued: socket $USER $CWD\n": this is printed when the lock is
# held, and another process wants it. The lock is still held.
#
# "bye\n": this is sent as a response to the "exit\n" command. If any
# locks were held, they are now released. After printing this
# response, the process will exit.
# "bye $TIMESTAMP\n": this is sent as a response to the "exit\n"
# command. If any locks were held, they are now released. After
# printing this response, the process will exit. The timestamp is
# on the same format as in the "locked" message. If a lock was,
# the timestamp refers to a time immediately before the lock was
# released.
import socket
import select
......@@ -85,6 +90,11 @@ LOCKNAME = "locksuite.lock"
__reported_queued = {}
def now():
t = time.time()
s = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t))
return s + ("%06.6f" % (t - int(t)))[1:]
def try_socket():
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
......@@ -230,16 +240,17 @@ def main():
s = get_socket_lock()
link = get_link_lock()
if link != None:
print "locked"
print "locked", now()
sys.stdout.flush()
while 1:
poll_input(s, 3600)
finally:
when = now()
if s != None:
s.close()
if link != None:
os.unlink(link)
print "bye"
print "bye", now()
sys.stdout.flush()
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment