From: | "Magnus Hagander" <mha(at)sollentuna(dot)net> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, <mark(at)mark(dot)mielke(dot)cc>, "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>, <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Stats collection on Windows |
Date: | 2006-04-05 14:42:40 |
Message-ID: | 6BCB9D8A16AC4241919521715F4D8BCEA35255@algol.sollentuna.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> >> What happens if process Y goes away between the time you obtain a
> >> handle for it and the time you try to run this
> DuplicateHandle call?
>
> > I can put together some quick test-code for this if you need me to?
>
> Nah, it was just a rhetorical question meant to poke a hole
> in the claim that Windows can avoid race conditions by using HANDLEs.
That's what I thought, which is why I asked first.
> AFAICS, don't-reuse-PIDs-too-quick has exact analogs that
> Windows has to solve by ensuring it doesn't reuse HANDLEs too quick.
Windows doesn't "reuse HANDLEs" in that way. Handles are like file
descriptors.
The kernel structure represnting the process has a *process id*, not a
handle. That is what uniquely identifies the process. (In the kernel
it's often referred to as a "client id").
The process structure will be held as long as anybody has an open handle
to the process. Thus, as long as this happens, the pid *cannot* be
reused. So one way to assure the pid isn't recycled too soon is to keep
the postmasters handle open "long enough" (the postmaster already has a
handle there - it's just the pgstats process that doesn't have one).
RIght now we close the postmaster handle first (win32_removechild at ~
2086 in postmaster.c) and then fire off the message (CleanupBackend at
~2239).
//Magnus
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2006-04-05 14:44:12 | Re: commit callback, request |
Previous Message | stephen joseph butler | 2006-04-05 14:42:19 | Re: Stats collection on Windows |