On Sat, 27 Nov 1999, Rob King wrote:
>
> How would you recommend I do it? Please remember, I have no experience
> with pthreads, and any advice you give would be greatly appreciated.
There are couple of ways you could do this:
1) pass sd2's value instead of its memory address to serverstart()
pthread_create(&thread1, pthread_attr_default,serverstart, sd2);
then inside serverstart:
void serverstart (void *p)
{
int sockfd = (int) p;
....blah...blah
}
if you worry about void * being not as the same size as int on
some platforms, then u should use 2)
2) Use a mutex lock:
pthread_mutex_lock (&mp_lock);
_do_the_accept_
_create_thread_
inside serverstart(), right after u def' the pointer, do this
pthread_mutex_unlock (&mp_lock);
>
> I tried doing a pool of threads created at startup, and I think that may
> be a better approach...That would allow tighter control of resource limits
> - do something like Apache, have a "maximum number" of processes running.
Yes, that's a better approach in many cases. Creating threads itself
is a quiet expensive operation.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message