You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by h iroshan <ir...@gmail.com> on 2009/07/01 12:14:30 UTC
Re: Creating a new thread inside a module
Hi William and Mladen,
Thanks both of you but i am still struggling with my thread creation. I
create my background thread inside the balancer_init method at
mod_proxy_balancer module. But after finished the execution of balancer_init
method my thread also terminate automatically please help me
Iroshan.
Re: Creating a new thread inside a module
Posted by h iroshan <ir...@gmail.com>.
Hi All,
I am still unable to create a new thread inside the balancer_init function.
Here the way that I tried. But in this way new thread was created and it
terminate after the balancer_init function finish its context. I want run
this new thread for ever until the server stop. Please help me to solve this
problem...
static int balancer_init(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
apr_status_t rv;
apr_thread_t *tp;
apr_threadattr_t *thd_attr;
rv =apr_thread_create(&tp, thd_attr, doit, ptemp, p);
apr_thread_detach(tp);
//do some thing here
//
//
return 0;
}
here is the function passes for creation new thread
static void* APR_THREAD_FUNC doit(apr_thread_t *thread, void *data)
{
while(1){
printf("ok");
//do some thing here
}
}
Iroshan.
Re: Creating a new thread inside a module
Posted by shaniro herath <sh...@gmail.com>.
Hi,
please can anybody roughly tell me how to register a new thread under the
main child thread pool .It is great help for me.
Shaniro Herath.
On Wed, Jul 1, 2009 at 9:44 PM, William A. Rowe, Jr. <wr...@rowe-clan.net>wrote:
> h iroshan wrote:
> >
> > Hi William and Mladen,
> >
> > Thanks both of you but i am still struggling with my thread creation. I
> > create my background thread inside the balancer_init method at
> > mod_proxy_balancer module. But after finished the execution of
> > balancer_init method my thread also terminate automatically please help
> me
>
> Watch which pool you create the thread in. Also your thread can terminate
> whenever it wants to return; - it's up to your code to keep itself alive.
>
Re: Creating a new thread inside a module
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
h iroshan wrote:
>
> Hi William and Mladen,
>
> Thanks both of you but i am still struggling with my thread creation. I
> create my background thread inside the balancer_init method at
> mod_proxy_balancer module. But after finished the execution of
> balancer_init method my thread also terminate automatically please help me
Watch which pool you create the thread in. Also your thread can terminate
whenever it wants to return; - it's up to your code to keep itself alive.
Re: Creating a new thread inside a module
Posted by Mladen Turk <mt...@apache.org>.
shaniro herath wrote:
> Hi Iroshan and All,
>
> Same problem here. I passed function with infinite while loop when
> creating the thread . Thread creation is done inside a function of
> another module. But after call the module function thread also
> terminate. What are the steps that I have missed here.
>
Make sure you guys use the correct pool for thread creation.
The best is to use the child's main pool or to create
the child pool from it.
Regards
--
^(TM)
Re: Creating a new thread inside a module
Posted by shaniro herath <sh...@gmail.com>.
Hi Iroshan and All,
Same problem here. I passed function with infinite while loop when creating
the thread . Thread creation is done inside a function of another module.
But after call the module function thread also terminate. What are the steps
that I have missed here.
Thank you.
Shaniro Herath
On Wed, Jul 1, 2009 at 3:44 PM, h iroshan <ir...@gmail.com> wrote:
>
> Hi William and Mladen,
>
> Thanks both of you but i am still struggling with my thread creation. I
> create my background thread inside the balancer_init method at
> mod_proxy_balancer module. But after finished the execution of balancer_init
> method my thread also terminate automatically please help me
>
> Iroshan.
>