Commit graph

5 commits

Author SHA1 Message Date
Vladislav Vaintroub
361fa97258 Bug #42804 --parallel option does not work for MTR under ActiveState
perl 

The problem here was the method how MTR gets its unique thread ids.
Prior to this patch, the method to do it was to maintain a global 
table of pid,mtr_unique_id) pairs. The table was backed by a text 
file. The table was cleaned up one in a while and dead processes leaking
unique_ids were determined with with kill(0) or with scripting tasklist
on Windows.

This method is flawed specifically on native Windows Perl. fork() is 
implemented with starting a new thread, give it a syntetic negative PID
(threadID*(-1)), until this thread creates a new process with exec()
However,  neither tasklist nor any other native Windows tool can cope with
negative perl PIDs. This lead to incorrect determination of dead process 
and reusing already used mtr_unique_id.

The patch introduces alternative portable  method of solving unique-id 
problem. When a process needs a unique id in range [min...max], it just 
starts  to open files named min, min+1,...max in a loop . After file is 
opened, we do non-blocking flock(). When flock() succeeds, process has 
allocated the ID. When process dies, file is unlocked . Checks for zombies 
are not necessary.

Since the change would create a co-existence problems with older version
of MTR, because of different way to calculate IDs, the default ID range
is changed from 250-299 to 300-349.

Another fix that was necessary enable --parallel option was to serialize 
spawn() calls on Windows. specifically, IO redirects needed to be protected.

This patch also fixes hanging CRTL-C (as described in Bug #38629) for the
"new"  MTR. The fix was already in 6.0 and is now downported.
2009-04-23 13:35:02 +02:00
Bjorn Munch
23b7f4e4b2 Bug #43132 Pusbbuild 2 host sol10 sparc64 max is not running tests due to port unavailble
MTR gives up if wanted port not available
Try next range if set to 'auto'
Also, use next number for additional threads if explicitly set
2009-03-04 11:34:47 +01:00
Vladislav Vaintroub
7a6c62c4ff Bug#42427 : MTR v2 fails with "can't write to /tmp/mysql-test-ports.sem" on Windows
- /tmp directory is not guaranteed to exist on Windows. 
Use the value of environment variable TEMP here
2009-02-09 13:10:34 +01:00
Magnus Svensson
788362de81 Debug printouts 2008-08-11 10:41:23 +02:00
Magnus Svensson
c431b23bae Fixup mtr_unique. Remove usage of ps and grep. Make it a module. Move _process_alive to Platform.pm. Rename opt_baseport to baseport, it's not an option 2008-08-10 19:46:43 +02:00