state-threads
[Top] [All Lists]

Re: Private Data

To: state-threads@xxxxxxxxxxx
Subject: Re: Private Data
From: mja@xxxxxxxxxxxxxxxxxxx (Mike Abbott)
Date: Tue, 14 Nov 2000 10:07:46 -0800 (PST)
In-reply-to: <3A109841.94B84A45@xxxxxxxx> from "Danil Melomedman" at Nov 13, 2000 08:41:21 PM
Sender: owner-state-threads@xxxxxxxxxxx
> I am putting together a POP3 server. It allocates a structure per
> message, all those structures must be private. There's also an array of
> pointers to those structs (should also be private). What would be a good
> approach to use st_thread_setspecific() so that none of the structures
> are damaged?

State threads share an address space so there's no way to protect one
thread's "private" data from accidental or malicious damage by another
thread.  The only way to prevent such damage is to use separate address
spaces which usually implies separate processes.  However, this usually
isn't necessary.

> Do I need a key per malloced struct?

Impractical.  There are only 16 keys in the default distribution
(ST_KEYS_MAX) so you'd quickly run out.  Instead use just one key to
store a pointer to a structure that contains all of the data (and/or
pointers to additional data) for one thread.  All the data is out there;
each thread just needs a unique starting point for wading through it.
-- 
Michael J. Abbott        mja@xxxxxxx        http://reality.sgi.com/mja/

<Prev in Thread] Current Thread [Next in Thread>
  • Private Data, Danil Melomedman
    • Re: Private Data, Mike Abbott <=