[patch iwhd] Fix a race in t/mongo-restart

Jim Meyering jim at meyering.net
Tue Oct 25 16:56:34 UTC 2011


Pete Zaitcev wrote:
> Ian McLeod found that on his system mongod takes a while from the moment
> it stopped listening until the time it releases the data lock, so the
> newly started mongo fails to lock and exits. Then, build-time checks fail.
>
> The fix is to poll of mongo actually exiting, and not merely stopping
> listening. This is made simple by knowing the right PID. Hopefuly it's
> not reused too quickly.
>
> ---
>  t/mongo-restart |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/mongo-restart b/t/mongo-restart
> index 1447952..eb0da4f 100755
> --- a/t/mongo-restart
> +++ b/t/mongo-restart
> @@ -64,8 +64,8 @@ creation_evokes_201 b1
>
>  kill $mongo_pid
>
> -# Wait for mongo to stop listening.
> -no_mongo() { mongo localhost:$m_port < /dev/null; test $? != 0; }
> +# Wait for mongo to disappear. Takes a while sometimes.
> +no_mongo() { kill -s 0 $mongo_pid 2> /dev/null; test $? != 0; }
>  wait_for .1 50 no_mongo || fail_ failed to kill mongo
>
>  mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod &

Thanks, Pete and Ian.  That looks great.
I adjusted the first line of the commit log to start with
"tests: " and pushed it.


More information about the iwhd-devel mailing list