happy new Year for every body :)
iam sorry for posting this question in this day but iam need to solve it
i develop on unix service using c++ and problem is thread A1 in it that start from parent thread A and the A1 start other thread B1 then A1 terminate and B1 handle the request if i open lot of session threads that connect to test
pid = fork();
while(true)
{
s = accept(Socket,(struct sockaddr*)&client,&len);
if( s >-1)
{
printf("\n other client port %i\n",client.sin_port);
printf("\n client connected address %s \n",inet_ntoa(client.sin_addr));
re = new HandleResponse();
re->set_Client(s);
re->set_manager(share_manager);
r->addClient(re);
r->start();
printf("\n process accept \n");
}
else
{
printf("\n wait error connecting \n");
}
}
and CircularResponse() is
void CircularResponse::addClient(HandleResponse *r)
{
qclient->push_back(r);
}
void *CircularResponse::run()
{
HandleResponse *current;
int h = 1;
printf("handle Response Thread");
printf("\n Circular response \n");
while(true)
{
if(!qclient->empty())
{
current = qclient->front();
h = current->check_connect();
printf(" current->check_connect() %i \n",h);
printf(" thread %lu \n",current->self());
if(h==-1)
{
printf("\n here I kill thread %lu \n",current->self());
qclient->erase(std::remove(qclient->begin(),qclient->end(),current));
delete current;
if(qclient->size()==0)
{
printf("qclient is empty %i",qclient->size());
}
}
current->start();
printf("\n client connected %i \n",(int)qclient->size());
qclient->pop_front();
}
sleep(3);
}
printf("\n LTSC_Manager Finsh Job \n");
return NULL;
and handle response is
int HandleResponse::ProcessResponse()
{
int h =0;
printf("\n Read thread %lu \n",this->m_tid);
string Technology = "",Exchange = "",Switch = "" ;
h = read(Socket,&bbuf,sizeof(bbuf));
if(h == 0 )
{
printf("\n other Client Close \n");
close(Socket);
Socket = -1;
pthread_cancel(this->m_tid);
printf("\n done \n");
return -1;
}
IDriver * driver = NULL ;
CComponentsKernel* g = new CComponentsKernel();
IComponent* comp = g->CreateComponent("TL1 Parser");
vector<CParserOutNode> m_Param;
char *TestType = NULL;
map<string,string> m_Tl1ParamsMap;
if(comp)
....
....
so problem is sometimes the last two thread go to zombie state is this design pattern is true or not or there are error in design hint this is all inherit form pthread class