On 2007-08-29 18:36:12 -0400, Guy Hulbert wrote:
> On Wed, 2007-08-29 at 18:03 -0400, Charlie Brady wrote:
> > That is just asserting that no single process could receive two 
> > connections in the same tick of time() (because if it could, it's
> > trivial 
> 
> Just assume that time() can have the granularity of the CPU instruction
> counter[1].

It could (if your perl implementation uses 128 bit long doubles), but it
isn't guaranteed to have that. You have to plan for the worst case and
that's probably a 60 Hz counter.

Here are some (measured) resolutions of gettimeofday on various systems:

Linux/i386:      1 ms
Linux/SPARC:     2 ms
HP-UX/PA-RISC:   2 ms
Linux/Alpha:   976 ms (1024 Hz)

Ok, so the Alpha is obsolete, and Sun and HP hardware seems to include a
timer with reasonably high resolution (both systems are a bit old I'd
expect newer gear get . I don't know anything about
PowerPC hardware though, and maybe we should worry about ARM for
embedded devices (although it could be argued that this is the least
problem for anybody building a mail-toaster on very small hardware).


> However, with a 16 bit PID and 65K processors you might run
> into collisions with the PID ...

I don't know see that follows. The PID still has to be unique at any
particular time. If a system can run more than 32k processes in parallel
it must use a 32 bit PID. 

The combination of hires time and pid is more likely to be non-unique
for an async server. It might be possible to call accept() and
gettimeofday() twice within the same microsecond.

> but I doubt anyone has a connection machine to run qpsmtpd on.
> 
> I think time() + PID is sufficient "for now" ... unless threads share
> the PID ...

They do on most systems - but you could use the TID instead of the PID.

> ( otoh, qpsmtpd is not even threaded is it ? ).

It might be possible to run Apache::Qpsmtpd on a multithreaded Apache.

        hp

-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | [EMAIL PROTECTED]         |
__/   | http://www.hjp.at/ |    -- Sam in "Freefall"

Attachment: signature.asc
Description: Digital signature

Reply via email to