susantha    2003/08/14 07:03:14

  Modified:    c/src/engine SerializerPool.cpp Main.c DeserializerPool.cpp
                        AxisEngine.cpp Axis.cpp
  Log:
  some improvements
  
  Revision  Changes    Path
  1.2       +26 -4     xml-axis/c/src/engine/SerializerPool.cpp
  
  Index: SerializerPool.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/SerializerPool.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SerializerPool.cpp        13 Aug 2003 14:07:47 -0000      1.1
  +++ SerializerPool.cpp        14 Aug 2003 14:03:14 -0000      1.2
  @@ -21,14 +21,36 @@
   //pooling should be implemented
   int SerializerPool::GetInstance(SoapSerializer** ppSZ)
   {
  -     //TODO
  -     *ppSZ = new SoapSerializer();
  +     lock();
  +     if (!m_SZList.empty())
  +     {
  +             *ppSZ = m_SZList.front();
  +             m_SZList.pop_front();
  +     }
  +     else
  +     {
  +             *ppSZ = new SoapSerializer();
  +     }
  +     if (!(*ppSZ))
  +     {
  +             unlock();
  +             return FAIL;            
  +     }
  +     if (SUCCESS != (*ppSZ)->Init())
  +     {
  +             m_SZList.push_back(*ppSZ);
  +             *ppSZ = NULL;
  +             unlock();
  +             return FAIL;
  +     }
  +     unlock();
        return SUCCESS;
   }
   
   int SerializerPool::PutInstance(SoapSerializer* pSZ)
   {
  -     //TODO
  -     delete pSZ;
  +     lock();
  +     m_SZList.push_back(pSZ);
  +     unlock();
        return SUCCESS;
   }
  
  
  
  1.7       +6 -7      xml-axis/c/src/engine/Main.c
  
  Index: Main.c
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/Main.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Main.c    13 Aug 2003 14:07:47 -0000      1.6
  +++ Main.c    14 Aug 2003 14:03:14 -0000      1.7
  @@ -183,6 +183,7 @@
   
   int main() 
   {            
  +     int xx;
        Ax_soapstream* str = (Ax_soapstream*)malloc(sizeof(Ax_soapstream));
        str->trtype = APTHTTP;
        str->sessionid = "somesessionid";
  @@ -190,21 +191,21 @@
   
        str->so.http.ip_headers = (Ax_header*)malloc(sizeof(Ax_header));
        str->so.http.ip_headers->headername = SOAPACTIONHEADER;
  -     str->so.http.ip_headers->headervalue = "\"CalculatorService\""; 
  +     str->so.http.ip_headers->headervalue = "\"Calculator\"";        
        str->so.http.ip_headercount = 1;
   
        printf("soap request :\n %s\n", ip);
   
        initialize_module();
  -     process_request(str);   
  +     for (xx =0; xx < 100 ; xx++)
  +             process_request(str);   
   
        return 0;
   }
   
   int send_response_bytes(char * res, void* pOutputStream) {
   
  -     printf("sending SOAP response : \n%s\n", res);
  -
  +//   printf("sending SOAP response : \n%s\n", res);
        return 0;
   }
   
  @@ -212,10 +213,8 @@
   
        req[0]= '\0';
        strcat(req, ip);
  -     printf("strlen(ip)%d", strlen(ip));
  +//   printf("strlen(ip)%d", strlen(ip));
        *retsize= strlen(ip);
  -     
  -
        return 0;
   }
   
  
  
  
  1.2       +28 -6     xml-axis/c/src/engine/DeserializerPool.cpp
  
  Index: DeserializerPool.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/DeserializerPool.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeserializerPool.cpp      13 Aug 2003 14:07:47 -0000      1.1
  +++ DeserializerPool.cpp      14 Aug 2003 14:03:14 -0000      1.2
  @@ -18,16 +18,38 @@
   
   }
   
  -int DeserializerPool::GetInstance(SoapDeSerializer** ppSZ)
  +int DeserializerPool::GetInstance(SoapDeSerializer** ppDZ)
   {
  -     //TODO
  -     *ppSZ = new SoapDeSerializer();
  +     lock();
  +     if (!m_DZList.empty())
  +     {
  +             *ppDZ = m_DZList.front();
  +             m_DZList.pop_front();
  +     }
  +     else
  +     {
  +             *ppDZ = new SoapDeSerializer();
  +     }
  +     if (!(*ppDZ))
  +     {
  +             unlock();
  +             return FAIL;            
  +     }
  +     if (SUCCESS != (*ppDZ)->Init())
  +     {
  +             m_DZList.push_back(*ppDZ);
  +             *ppDZ = NULL;
  +             unlock();
  +             return FAIL;
  +     }
  +     unlock();
        return SUCCESS;
   }
   
  -int DeserializerPool::PutInstance(SoapDeSerializer* pSZ)
  +int DeserializerPool::PutInstance(SoapDeSerializer* pDZ)
   {
  -     //TODO
  -     delete pSZ;
  +     lock();
  +     m_DZList.push_back(pDZ);
  +     unlock();
        return SUCCESS;
   }
  
  
  
  1.15      +2 -11     xml-axis/c/src/engine/AxisEngine.cpp
  
  Index: AxisEngine.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/AxisEngine.cpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AxisEngine.cpp    13 Aug 2003 14:07:47 -0000      1.14
  +++ AxisEngine.cpp    14 Aug 2003 14:03:14 -0000      1.15
  @@ -97,6 +97,8 @@
   
   AxisEngine::~AxisEngine()
   {
  +     if (m_pSZ) g_SerializerPool.PutInstance(m_pSZ);
  +     if (m_pDZ) g_DeserializerPool.PutInstance(m_pDZ);
   }
   
   int AxisEngine::Process(Ax_soapstream* soap) 
  @@ -371,18 +373,7 @@
        int Status;
        //Create and initialize Serializer and Deserializer objects
        if (SUCCESS != (Status = g_SerializerPool.GetInstance(&m_pSZ))) return Status;
  -     if (SUCCESS != (Status = m_pSZ->Init()))
  -     {
  -             g_SerializerPool.PutInstance(m_pSZ);
  -             return Status;
  -     }
        if (SUCCESS != (Status = g_DeserializerPool.GetInstance(&m_pDZ))) return 
Status;
  -     if (SUCCESS != (Status = m_pDZ->Init()))
  -     {
  -             g_DeserializerPool.PutInstance(m_pDZ);
  -             return Status;
  -     }
  -
        return SUCCESS;
   }
   
  
  
  
  1.7       +1 -0      xml-axis/c/src/engine/Axis.cpp
  
  Index: Axis.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/Axis.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Axis.cpp  13 Aug 2003 14:07:47 -0000      1.6
  +++ Axis.cpp  14 Aug 2003 14:03:14 -0000      1.7
  @@ -80,6 +80,7 @@
                                        DEBUG1("Status = engine->Process(str);");
                                    DEBUG1("are we successful?");            
                                        Status = SUCCESS;
  +                                     delete engine;
                                }
                        }
                        //Handler the GET method
  
  
  

Reply via email to