By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,369 Members | 966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,369 IT Pros & Developers. It's quick & easy.

cannot use __try in functions that require object unwinding

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

Expand|Select|Wrap|Line Numbers
  1. DWORD WINAPI MAC_out_Thread( LPVOID lpParam ) {
  2.  
  3.  
  4.    int size_of_LLC_out_Queue= 0;
  5.  
  6.    mac_frame MAC_FRAME_TEMPLATE;
  7.  
  8.  
  9.  
  10.  
  11.  DWORD  MAC_QU_WaitResult, LLC_QU_WaitResult, ARP_TABLE_WaitResult;
  12.  
  13.  LLC_QU_WaitResult =  WaitForSingleObject(LLC_out_Queue_Mutex,INFINITE); 
  14. string mac = GetMACaddress();
  15.  
  16. while(1){           
  17.       switch (LLC_QU_WaitResult) 
  18.         {
  19.            case WAIT_OBJECT_0: 
  20.                 __try { 
  21.                  ARP_TABLE_WaitResult =  WaitForSingleObject(ARP_table_Mutex,INFINITE); 
  22.                     switch (ARP_TABLE_WaitResult) 
  23.                              {
  24.                                  case WAIT_OBJECT_0: 
  25.                                  __try { 
  26.                                       size_of_LLC_out_Queue = LLC_out_Queue.size();
  27.                                       if(size_of_LLC_out_Queue > 0)
  28.                                         {
  29.                                    ARP_iterator = ARP.find(LLC_out_Queue[LLC_out_Queue.size() - 1].data.DIP); 
  30.                                     if (ARP_iterator != ARP.end())
  31.                                     strcpy(MAC_FRAME_TEMPLATE.DA,ARP_iterator->second.c_str());
  32.                                        else
  33.                                     strcpy(MAC_FRAME_TEMPLATE.DA,FAKE_MAC_Switch.c_str());
  34.                                     MAC_FRAME_TEMPLATE.data = LLC_out_Queue[LLC_out_Queue.size() - 1];
  35.                                     strcpy(MAC_FRAME_TEMPLATE.SA,mac.c_str());
  36.                                     LLC_out_Queue.pop_back();
  37.                                     MAC_out_Queue.push_back(MAC_FRAME_TEMPLATE);
  38.                                         }
  39.                                         }
  40.                                  __finally { 
  41.                                   ReleaseMutex(ARP_table_Mutex);
  42.                                        }
  43.  
  44.                              }
  45.                     }
  46.               __finally { 
  47.                  ReleaseMutex(LLC_out_Queue_Mutex);
  48.                  }
  49.                break;
  50.          }
  51.  
  52.  
  53.  
  54.       Sleep(400);
  55.       LLC_QU_WaitResult =  WaitForSingleObject(LLC_out_Queue_Mutex,INFINITE); 
  56.  
  57.     }
  58.  
  59.  
  60.     return 0; 
  61.  
  62. }
  63.  
Oct 1 '10 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
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.
Oct 1 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.