Protocol.cpp

См. документацию.
00001 /*
00002  * Protocol.cpp
00003  *
00004  *  Created on: 09.04.2011
00005  *      Author: nick
00006  */
00007 
00008 #include "Protocol.h"
00009 #include <errno.h>
00010 
00011 /*template <class Listener_T>
00012 Protocol<Listener_T>::Protocol() {
00013         // TODO Auto-generated constructor stub
00014 }*/
00015 void* node_threadFunc(void* clnt) {
00016     pair<Protocol*, Node*>* pv = static_cast<pair<Protocol*, Node*>*> (clnt);
00017     Protocol* pt = pv->first;
00018     Node* cn = pv->second;
00019     delete pv;
00020     pt->handlerNode(cn);
00021     //=====123
00022 
00023     pthread_mutex_lock(&(pt->mutDelEndNodRu));
00024     --(pt->num_run_threads);
00025     if((pt->num_run_threads)==0){pthread_cond_signal(&(pt->cond_del_element));}
00026     pthread_mutex_unlock(&(pt->mutDelEndNodRu));
00027 
00028     //=====123
00029 /*    pthread_mutex_lock(&(pt->cs_mutexUNIC));
00030     if((--(pt->num_run_threads))==0){
00031         #ifdef debug_output
00032         debug_out cout<<"Разблокируем мьютекс потоков"<<endl;
00033         #endif
00034         pthread_mutex_unlock(&pt->cs_mutexEndWork);
00035     }
00036     pthread_mutex_unlock(&(pt->cs_mutexUNIC));*/
00037     return NULL;
00038 }
00039 
00040 void
00041 characterData(void *userData, const XML_Char *s, int len) {
00042     Protocol* protocol = (Protocol*) userData;
00043     protocol->curNode->addXMLBody(string(s, len));
00044     #ifdef debug_output
00045     static pthread_mutex_t deta_m=PTHREAD_MUTEX_INITIALIZER;
00046     pthread_mutex_lock(&deta_m);
00047     cout<<"deta!:"<<string(s,len)<<endl;
00048     pthread_mutex_unlock(&deta_m);
00049     #endif
00050 }
00051 
00052 void
00053 startTag(void *userData, const XML_Char *name, const XML_Char **atts) {
00054     #ifdef debug_output
00055     cout << "start_tag" << endl;
00056     #endif
00057     Protocol* protocol = (Protocol*) userData;
00058     protocol->curDeph++;
00059     map<string, string> attrsMap;
00060     const XML_Char **curAttr = atts;
00061     while (*curAttr != NULL) {
00062         #ifdef debug_output
00063         cout << "name:" << *curAttr << " value: " << *(curAttr + 1) << endl;
00064         #endif
00065         attrsMap[*curAttr] = *(curAttr + 1);
00066         curAttr = curAttr + 2;
00067     }
00068     pthread_mutex_lock(&(protocol->cs_mutexNewNode));
00069     Node* curNode = new Node(name, attrsMap, protocol->curNode);
00070     pthread_mutex_unlock(&(protocol->cs_mutexNewNode));
00071     if(protocol->curNode==NULL){
00072         protocol->topNode=curNode;
00073     }
00074     protocol->curNode = curNode;
00075     if (protocol->curDeph == 1) {
00076         protocol->startXMLTagNodeHandler(curNode);
00077     }
00078 }
00079 
00080 void
00081 endTag(void *userData, const XML_Char *name) {
00082     #ifdef debug_output
00083     cout << "end_tag" << endl;
00084     #endif
00085     Protocol* protocol = (Protocol*) userData;
00086     protocol->curDeph--;
00087     //protocol->curNode=protocol->curNode->getParent();
00088     Node* curnP = protocol->curNode->getParent();
00089     if (protocol->curDeph == 1) {//Пока нет начального тега!
00090         //if (protocol->curDeph==0){
00091         //      Node* curn=curNode;
00092         //      curNode=curn->getParent();
00093         pair<Protocol*, Node*>* pv = new pair<Protocol*, Node*>(protocol, protocol->curNode);
00094         //====
00095         pthread_mutex_lock(&(protocol->mutDelEndNodRu));
00096         ++(protocol->num_run_threads);
00097         pthread_mutex_unlock(&(protocol->mutDelEndNodRu));
00099         //pthread_mutex_lock(&(protocol->cs_mutexUNIC));
00100         //pthread_mutex_trylock(&protocol->cs_mutexEndWork);
00101         //++protocol->num_run_threads;
00102         //pthread_mutex_unlock(&(protocol->cs_mutexUNIC));
00104         pthread_create(&(protocol->nodeThread), &(protocol->attr), node_threadFunc, pv);
00105         //node_threadFunc(pv);
00106         //====
00107         //protocol->handlerNode(protocol->curNode);
00108     } else {
00109         if (protocol->curDeph == 0) {
00110             protocol->endXMLTagNodeHandler(protocol->curNode);
00111         }
00112         //protocol->curNode=protocol->curNode->getParent();
00113     }
00114     protocol->curNode = curnP;
00115     //===!!!
00116     /*  if (protocol->curDeph==1){//Пока нет начального тега!
00117             //if (protocol->curDeph==0){
00118                     protocol->handlerNode();
00119             }else if (protocol->curDeph==0){
00120                     protocol->endXMLTagNodeHandler(protocol->curNode);
00121                     protocol->curNode=protocol->curNode->getParent();
00122             }else{
00123                     protocol->curNode=protocol->curNode->getParent();
00124             }*/
00126     #ifdef debug_output
00127     cout << "== end end tag!== " << endl;
00128     #endif
00129 }
00130 
00131 void Protocol::startXMLTagNodeHandler(Node* node) {
00132 
00133 }
00134 
00135 void Protocol::endXMLTagNodeHandler(Node* node) {
00136 
00137 }
00138 
00139 void Protocol::handlNodes(Node* curNodeL, TagHandelrsMapT::iterator begin, TagHandelrsMapT::iterator end) {
00140     #ifdef debug_output
00141     cout << "handle_nodes" << endl;
00142     #endif
00143     TagHandelrsMapT::iterator it = begin;
00144     while (it != end) {
00145         (*it).second->handleTag(*curNodeL);
00146         it++;
00147     }
00148 }
00149 
00150 /*void Protocol::handlIQs(IQHandelrsMapT::iterator begin,IQHandelrsMapT::iterator end,TagIQ &iq){
00151         cout<<"handle_IQs"<<endl;
00152         IQHandelrsMapT::iterator it=begin;
00153         //cout<< "IQTname: "<<iq.getSubNode()->getName()<<" IQTNS: "<<iq.getSubNode()->getNamesapace()<<endl;
00154         while (it!=end){
00155                 cout<< "Handle node IQ!"<<endl;
00156                 //Вероятно сама нода должна обрабатываться в отдельном потоке
00157                 (*it).handler->handleTag(iq);
00158                 it++;
00159         }
00160 }*/
00161 
00162 void Protocol::handlerIQ(Node* curNodeL) {
00163     IQHandelrsMapT::iterator it = iqHandlers.begin();
00164     //IQHandelrsMapT::iterator it2;
00165     TagIQ iq(*curNodeL); //=new TagIQ(*curNode);
00166     while (it != iqHandlers.end()) {
00167         Node* subnode = NULL;
00168         if (it->xmlns != "") {
00169             subnode = iq.getKind(it->xmlns);
00170             if ((subnode != NULL) &&
00171                     ((subnode->getName() == it->subtagName) || (it->subtagName == ""))) {
00172                 it->handler->handleTag(iq);
00173             }
00174         } else
00175             if (it->subtagName != "") {
00176             _Kinds_iterator it1 = iq.kindsNameBegin(it->subtagName);
00177             _Kinds_iterator it2 = iq.kindsNameEnd(it->subtagName);
00178             if (it1 != it2) {
00179                 it->handler->handleTag(iq);
00180             }
00181         } else {
00182             it->handler->handleTag(iq);
00183         }
00184         //if (((it->xmlns=="")||(it->xmlns==iq.))&&((it->subtagName)))
00185         ++it;
00186     }
00187     //Тут надо обработать эксепшон
00188     /*  Node* subn=iq.getSubNode();
00189             cout<<"DEBUG IQ HANDLERS"<<endl;
00190             for (IQHandelrsMapT::iterator iit=iqHandlers.begin();
00191                             iit!=iqHandlers.end();iit++){
00192                     cout<< "name: "<<(*iit).first.first<<" namespace: "<<(*iit).first.second<<endl;
00193             }
00194             cout<<"=== === === === =="<<endl;
00195             //Непонятно как работает сравнение у pair, операторы там перегружены в STL, но как то странно...
00196             //if (subn->getNamesapace().length()>0){
00197                     it1=iqHandlers.lower_bound(make_pair(subn->getName(),subn->getNamesapace()));
00198                     it2=iqHandlers.upper_bound(make_pair(subn->getName(),subn->getNamesapace()));
00199                     handlIQs(it1,it2,iq);
00200             //}
00201 
00202             cout<<"handlerIQ 1 name: "<<subn->getName()<< " namespace: "<<subn->getNamesapace()<<endl;
00203             if(subn->getNamesapace().length()>0){
00204                     it1=iqHandlers.lower_bound(make_pair(subn->getName(),""));
00205                     it2=iqHandlers.upper_bound(make_pair(subn->getName(),""));
00206                     handlIQs(it1,it2,iq);
00207             }
00208         cout<<"handlerIQ 2"<<endl;
00209 
00210         //if(subn->getName().length()>0){
00211             it1=iqHandlers.lower_bound(make_pair("",subn->getNamesapace()));
00212             it2=iqHandlers.upper_bound(make_pair("",subn->getNamesapace()));
00213             handlIQs(it1,it2,iq);
00214         //}
00215         cout<<"handlerIQ 3"<<endl;*/
00216     manadgeIQResp(iq);
00217     //Node* curn=curNode;
00218     //curNode=curn->getParent();
00219     //и удалять всегда
00220     //delete iq;
00221     //delete curn;
00222 }
00223 
00224 void Protocol::handlerNode(Node* curNodeL) {
00225     TagHandelrsMapT::iterator it1;
00226     TagHandelrsMapT::iterator it2;
00227     #ifdef debug_output
00228     cout << "handle node name:" << curNodeL->getName() << " namespace: " << curNodeL->getNamesapace() << endl;
00229     #endif
00230     //Непонятно как работает сравнение у pair, операторы там перегружены в STL, но как то странно...
00231     //if (curNode->getNamesapace().length()>0){
00232     it1 = tagHandlers.lower_bound(make_pair(curNodeL->getName(), curNodeL->getNamesapace()));
00233     it2 = tagHandlers.upper_bound(make_pair(curNodeL->getName(), curNodeL->getNamesapace()));
00234     handlNodes(curNodeL, it1, it2);
00235     //}
00236 
00237     if (curNodeL->getNamesapace().length() > 0) {
00238         it1 = tagHandlers.lower_bound(make_pair(curNodeL->getName(), ""));
00239         it2 = tagHandlers.upper_bound(make_pair(curNodeL->getName(), ""));
00240         handlNodes(curNodeL, it1, it2);
00241     }
00242 
00243     //if(curNode->getName().length()>0){
00244     it1 = tagHandlers.lower_bound(make_pair("", curNodeL->getNamesapace()));
00245     it2 = tagHandlers.upper_bound(make_pair("", curNodeL->getNamesapace()));
00246     handlNodes(curNodeL, it1, it2);
00247     //}
00248 
00249     //Пребор для qi,если iq
00250     if (curNodeL->getName() == "iq") {
00251         handlerIQ(curNodeL);
00252     }
00253     //  Node* curn=curNode;
00254     //  curNode=curn->getParent();
00255     pthread_mutex_lock(&cs_mutexNewNode);
00256     delete curNodeL;
00257     pthread_mutex_unlock(&cs_mutexNewNode);
00258 }
00259 
00260 void startDocType(void *userData, const XML_Char *doctypeName, const XML_Char *sysid,
00261         const XML_Char *pubid, int has_internal_subset) {
00262     #ifdef debug_output
00263     cout << "start doc type" << endl;
00264     #endif
00265 }
00266 
00267 void endDocType(void *userData) {
00268     #ifdef debug_output
00269     cout << "end doc type" << endl;
00270     #endif
00271 }
00272 
00273 void Protocol::parserCreate(int sktID) {
00274     xml_parser = XML_ParserCreate("UTF-8");
00275     if (!xml_parser) {
00276         std::cerr << "Couldn't allocate memory for parser\n";
00277         exit(-1);
00278     }
00279     curDeph = 0;
00280     XML_SetUserData(xml_parser, this);
00281     XML_SetCharacterDataHandler(xml_parser, characterData);
00282     XML_SetElementHandler(xml_parser, startTag, endTag);
00283     XML_SetDoctypeDeclHandler(xml_parser, startDocType, endDocType);
00284     skt_id = sktID;
00285 }
00286 
00287 void Protocol::startParsing(/*int sktID*/) {
00288     int len;
00289     //skt_id=sktID;
00290     do {
00291         #ifdef debug_output
00292         cout << "parse next buffer" << endl;
00293         #endif
00294         len = recv(skt_id, read_Buffer, BUFFSIZE, 0);
00295         if (len <= 0) {
00296             #ifdef debug_output
00297             cout << "1" << endl;
00298             #endif
00299             XML_Parse(xml_parser, read_Buffer, 0, 1);
00300             XML_ParserFree(xml_parser);
00301             break;
00302         } else {
00303             #ifdef debug_output
00304             cout << "2" << endl;
00305             #endif
00306             if (XML_Parse(xml_parser, read_Buffer, len, 0) == XML_STATUS_ERROR) {
00307                 cout << " XML ERROR! :" <<
00308                         XML_ErrorString(XML_GetErrorCode(xml_parser)) << "at line:" << XML_GetCurrentLineNumber(xml_parser) << endl;
00309                 break;
00310             }
00311         }
00312     } while (len > 0);
00313     //Ждем завершения ВСЕХ потоков
00314     #ifdef debug_output
00315     cout<<"Ждем все потоки, потоков:"<<num_run_threads<<endl;
00316     #endif
00317     //pthread_mutex_lock(&cs_mutexEndWork);
00318 
00319     pthread_mutex_lock(&mutDelEndNodRu);
00320     //Тут ждем переменную состояния
00321     while(num_run_threads!=0){pthread_cond_wait(&cond_del_element,&mutDelEndNodRu);}
00322     pthread_mutex_unlock(&mutDelEndNodRu);
00323 
00324     #ifdef debug_output
00325     cout<<"Дождались все потоки"<<endl;
00326     #endif
00327     //Непонятно зачем но valring что то хочет
00328     pthread_mutex_lock(&cs_mutexNewNode);
00329     if (topNode!=NULL){
00330         #ifdef debug_output
00331         cout<<"OK"<<endl;
00332         #endif
00333         delete topNode;
00334 
00335     }
00336     pthread_mutex_unlock(&cs_mutexNewNode);
00337     #ifdef debug_output
00338     cout<<"удалили корневую ноду"<<endl;
00339     #endif
00340 
00341     //123 pthread_mutex_unlock(&cs_mutexEndWork);
00342     #ifdef debug_output
00343     cout << "end working client" << endl;
00344     #endif
00345 }
00346 
00347 Protocol::Protocol() {
00348     #ifdef debug_output
00349     cout<<"конструктор протокола"<<endl;
00350     #endif
00351     
00352     curDeph = 0;
00353     curNode = NULL;
00354     topNode=NULL;
00355     curNodeSend = NULL;
00356     //addTagHandler(this,"iq","");
00357     //=======================================
00358     //pthread_mutexattr_init(&mutDelEndNodRuAttr);
00359     //pthread_mutexattr_settype(&mutDelEndNodRuAttr,PTHREAD_MUTEX_RECURSIVE);
00360     pthread_mutex_init(&mutDelEndNodRu,NULL/*&mutDelEndNodRuAttr*/);
00361     pthread_cond_init(&cond_del_element,NULL);
00362     num_run_threads=0;
00363     //=======================================
00364     pthread_mutex_init(&cs_mutex,NULL);
00365     pthread_mutex_init(&cs_mutex1,NULL);
00366 //123    pthread_mutex_init(&cs_mutexUNIC,NULL);
00367     //123 pthread_mutex_init(&cs_mutexEndWork,NULL);
00368     pthread_mutex_init(&cs_mutexNewNode,NULL);
00369     pthread_mutex_init(&cs_mutexDEL,NULL);
00370     pthread_attr_init(&attr);
00371     pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
00372     //Нахрена это надо но valgrind говорит о возможной ошибке
00373     //pthread_mutex_lock(&cs_mutexUNIC);
00374     
00375     //pthread_mutex_unlock(&cs_mutexUNIC);
00376 
00377 }
00378 
00379 //template <class Listener_T>
00380 
00381 void Protocol::addTagHandler(TagHandler<Node>::PTagHandler handler, string name, string xmlns) {
00382     tagHandlers.insert(make_pair(make_pair(name, xmlns), handler));
00383 }
00384 
00385 //bool delIQPredicate(IQHandleD hd){
00386     //cout<<"addr:"<<reinterpret_cast<long int> (hd.handler)<<"addr2:"<<reinterpret_cast<long int> (valPredIQDEL)<<" "<<(valPredIQDEL==hd.handler)<<endl;
00387     //return valPredIQDEL==hd.handler;
00388 //}
00389 
00390 void Protocol::removeIQHandler(TagHandler<TagIQ>::PTagHandler handler){
00391     pthread_mutex_lock(&cs_mutexDEL);
00392     IQHandelrsMapT::iterator it=iqHandlers.begin();
00393     while(it!=iqHandlers.end()){
00394         if(it->handler==handler){
00395             iqHandlers.erase(it);
00396             #ifdef debug_output
00397             cout<<"удалено"<<endl;
00398             #endif
00399             break;
00400         }
00401         ++it;
00402     }
00403   /*      valPredIQDEL=handler;
00404         int sz1=iqHandlers.size();
00405         remove_if(iqHandlers.begin(),iqHandlers.end(),delIQPredicate);
00406         cout<<"удалено элементов"<<sz1-iqHandlers.size()<<endl;*/
00407     pthread_mutex_unlock(&cs_mutexDEL);
00408 }
00409 
00410 void Protocol::addIQHandler(TagHandler<TagIQ>::PTagHandler handler, string xmlns, string name) {    
00411     #ifdef debug_output
00412     cout << "add iq handler" << name << " " << xmlns << endl;
00413     #endif
00414     IQHandleD hd;
00415     hd.xmlns = xmlns;
00416     hd.subtagName = name;
00417     hd.handler = handler;
00418     pthread_mutex_lock(&cs_mutexDEL);
00419     iqHandlers.push_back(hd);
00420     pthread_mutex_unlock(&cs_mutexDEL);
00421     //iqHandlers.insert(make_pair(make_pair(name,xmlns), handler));    
00422 }
00423 
00424 void Protocol::sendString(string data) {
00425     pthread_mutex_lock(&cs_mutex);
00426     #ifdef debug_output
00427     cout << "send string" << endl << "DATA:" << data << endl;
00428     #endif
00429     const char* buf = data.data();
00430     int pos = 0;
00431     int err = 0;
00432     int l = data.length();
00433     while (pos < l) {
00434         err = send(skt_id, buf + pos, l - pos, 0);
00435         if (err > 0) {
00436             #ifdef debug_output
00437             cout << "A OK";
00438             #endif
00439             pos += err;
00440         } else {
00441             cout << "A ERR";
00442             break;
00443         }
00444     }
00445     pthread_mutex_unlock(&cs_mutex);
00446 }
00447 //template <class Listener_T>
00448 
00449 void Protocol /*<Listener_T>*/::sendNode(Node &stanza) {
00450     sendString(stanza.toXMLString());
00451 }
00452 
00453 void Protocol::sendNodeStart(Node &stanza) {
00454     sendString(stanza.toXMLStringStart());
00455 }
00456 
00457 void Protocol::sendNodeEnd(Node &stanza) {
00458     sendString(stanza.toXMLStringEnd());
00459 }
00460 
00461 void Protocol::manadgeIQResp(TagIQ& st) {
00462     //IQRespDKey key;
00463     //key.id=st.getID();
00464     //key.subtagName=st.getKind();//getSubNode()->getName();
00465     //key.xmlns=st.getSubNode()->getNamesapace();
00466     //multimap</*IQRespDKey*/string,IQRespD>::iterator b=req_id.lower_bound(st.getID());
00467     //multimap</*IQRespDKey*/string,IQRespD>::iterator be=req_id.upper_bound(st.getID());
00468     pthread_mutex_lock(&cs_mutex1);
00469     pair<multimap<string, IQRespD>::iterator, multimap<string, IQRespD>::iterator> it = req_id.equal_range(st.getID());
00470     #ifdef debug_output
00471     cout << "respCount" << req_id.size() << endl;
00472     #endif
00473     while (it.first != it.second) {
00474         #ifdef debug_output
00475         cout << "iq from get F:" << st.getFrom() << endl;
00476         #endif
00477         IQRespD* rd = &(it.first->second);
00478         Node *n = st.getKind(rd->xmlns);
00479         if ((n != NULL) && (n->getName() == rd->subtagName)) {
00480             rd->result = st;
00481             struct sembuf sops;
00482             memset(&sops, 0, sizeof sops);
00483             sops.sem_op = 1;
00484             #ifdef debug_output
00485             cout << "===opening semaphore!!!===" << endl;
00486             #endif
00487             //На всякий случай, вдруг что
00488             //int csem=it.first->second.semID;
00489             int sem_id = rd->semID;
00490             //it.first->second.semID=-1;
00491             rd->semID = -1;
00492             semop(/*csemrd.semID*/sem_id, &sops, 1);
00493             semctl(/*csemrd.semID*/sem_id, 0, IPC_RMID);
00494         }
00495         ++it.first;
00496     }
00497     pthread_mutex_unlock(&cs_mutex1);
00498 }
00499 
00500 TagIQ Protocol::sendIQResp(TagIQ& st, string resultXMLNS, string resultSubTagName) {
00501 
00502     struct sembuf sops;
00503     int cursem;
00504     struct timespec timeout;
00505 
00506     memset(&sops, 0, sizeof sops);
00507     memset(&timeout, 0, sizeof timeout);
00508 
00509     cursem = semget(IPC_PRIVATE, 1, 0777 | IPC_CREAT);
00510     #ifdef debug_output
00511     cout << "SEMAPHORE IDENTIFIER!: " << cursem << " errNo:" << errno << endl;
00512     #endif
00513     //ENOMEM
00514     sops.sem_op = -1;
00515     timeout.tv_sec = 600;
00516     //IQRespDKey key;
00519     //key.
00520     pthread_mutex_lock(&cs_mutex1);
00521     string key = st.getID();
00522     IQRespD rd;
00523     rd.semID = -1;
00524     multimap<string, IQRespD>::iterator it = req_id.insert(make_pair(key, rd));
00525 
00526     it->second.semID = cursem;
00527     it->second.subtagName = resultSubTagName;
00528     it->second.xmlns = resultXMLNS;
00529     pthread_mutex_unlock(&cs_mutex1);
00530     //req_id[key].semID=cursem;
00531     //req_id[key].resultXMLNS=resultXMLNS;
00532 
00533     sendNode(st);
00534 
00535 
00536     //Тут ждать открытия семафора
00537     semtimedop(cursem, &sops, 1, &timeout);
00538 
00540     //cout<<"iq from get:"<<req_id[key].result.getFrom()<<endl;
00541     pthread_mutex_lock(&cs_mutex1);
00542     TagIQ res(it->second.result); //req_id[key].result;
00543     req_id.erase(it/*key*/);
00544     pthread_mutex_unlock(&cs_mutex1);
00546     return res;
00547 }
00548 
00549 /*bool operator<(const IQRespDKey &obj1, const IQRespDKey &obj2){
00550         return (obj1.id<obj2.id) && (obj1.subtagName<obj2.subtagName) && (obj1.xmlns<obj2.xmlns);
00551 }*/
00552 
00553 //bool IQRespDKey::operator<(const IQRespDKey &obj2) const{
00554 //      return (this->id<obj2.id) && (this->subtagName<obj2.subtagName) && (this->xmlns<obj2.xmlns);
00555 //      return (this->id<obj2.id) || (this->subtagName<obj2.subtagName) || (this->xmlns<obj2.xmlns);
00556 //}
00557 
00558 /*bool IQRespDKey::operator==(const IQRespDKey &obj2) const{
00559         return (this->id==obj2.id) && (this->subtagName==obj2.subtagName) && (this->xmlns==obj2.xmlns);
00560 }
00561 
00562 bool IQRespDKey::operator!=(const IQRespDKey &obj2) const{
00563         return !((*this) == obj2);
00564 }*/
00565 /*void Protocol::handleTag(Node &tag){
00566         //tag1->getAttribute("xmlns");
00567         if (tag.getName()=="iq"){
00568                 handlerIQ();
00569         }
00570 }*/
00571 
00572 /*template <class Listener_T>*/
00573 Protocol::~Protocol() {
00574     // TODO Auto-generated destructor stub
00575     //req_id.erase
00576     //=========================================================
00577     //pthread_mutexattr_destroy(&mutDelEndNodRuAttr);
00578     pthread_mutex_destroy(&mutDelEndNodRu);
00579     pthread_cond_destroy(&cond_del_element);
00580     //=========================================================
00581     
00582     pthread_attr_destroy(&attr);    
00584     if(curNodeSend!=NULL){
00585         cout<<"delete curnodesend!"<<endl;
00586         delete curNodeSend;
00587     }
00588     cout<<"деструктор протокола"<<endl;
00589 //123    pthread_mutex_destroy(&cs_mutexUNIC);
00590     pthread_mutex_destroy(&cs_mutex);
00591     pthread_mutex_destroy(&cs_mutex1);
00592     pthread_mutex_destroy(&cs_mutexNewNode);
00593     pthread_mutex_destroy(&cs_mutexDEL);
00594 }
00595 
00596 IQRespD::~IQRespD() {
00597     if (semID != -1) {
00598         semctl(semID, 0, IPC_RMID);
00599     }
00600 }