cannot use __try in functions that require object unwinding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darko
    New Member
    • Sep 2006
    • 10

    #1

    cannot use __try in functions that require object unwinding

    can anybody point me where is the unwiding object in this code

    Code:
    DWORD WINAPI MAC_out_Thread( LPVOID lpParam ) {
    
    
       int size_of_LLC_out_Queue= 0;
              
       mac_frame MAC_FRAME_TEMPLATE;
    
    
    
    
     DWORD  MAC_QU_WaitResult, LLC_QU_WaitResult, ARP_TABLE_WaitResult;
      
     LLC_QU_WaitResult =  WaitForSingleObject(LLC_out_Queue_Mutex,INFINITE); 
    string mac = GetMACaddress();
    
    while(1){           
          switch (LLC_QU_WaitResult) 
            {
               case WAIT_OBJECT_0: 
                    __try { 
                     ARP_TABLE_WaitResult =  WaitForSingleObject(ARP_table_Mutex,INFINITE); 
                        switch (ARP_TABLE_WaitResult) 
                                 {
                                     case WAIT_OBJECT_0: 
                                     __try { 
                                          size_of_LLC_out_Queue = LLC_out_Queue.size();
                                          if(size_of_LLC_out_Queue > 0)
                                            {
                                       ARP_iterator = ARP.find(LLC_out_Queue[LLC_out_Queue.size() - 1].data.DIP); 
                                        if (ARP_iterator != ARP.end())
                                        strcpy(MAC_FRAME_TEMPLATE.DA,ARP_iterator->second.c_str());
                                           else
                                        strcpy(MAC_FRAME_TEMPLATE.DA,FAKE_MAC_Switch.c_str());
                                        MAC_FRAME_TEMPLATE.data = LLC_out_Queue[LLC_out_Queue.size() - 1];
                                        strcpy(MAC_FRAME_TEMPLATE.SA,mac.c_str());
                                        LLC_out_Queue.pop_back();
                                        MAC_out_Queue.push_back(MAC_FRAME_TEMPLATE);
                                            }
                                            }
                                     __finally { 
                                      ReleaseMutex(ARP_table_Mutex);
                                           }
                                        
                                 }
                        }
                  __finally { 
                     ReleaseMutex(LLC_out_Queue_Mutex);
                     }
                   break;
             }
            
    
    
          Sleep(400);
          LLC_QU_WaitResult =  WaitForSingleObject(LLC_out_Queue_Mutex,INFINITE); 
              
        }
        
    
        return 0; 
    
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    It's somewhere between the __try and the __finally.

    Bad code. The __try should be limited to one function call.

    With many calls in a __try block you can't tell how far you got into the block before the exception was thrown.

    So you may have done a little, or a lot, of processing.

    Comment

    Working...