]> git.sesse.net Git - casparcg/commitdiff
osc:
authorRobert Nagy <ronag@live.com>
Sun, 7 Jul 2013 08:38:29 +0000 (10:38 +0200)
committerRobert Nagy <ronag@live.com>
Sun, 7 Jul 2013 08:38:29 +0000 (10:38 +0200)
-Removed unnecessary buffers.empty() check.
-Catch any exceptions in osc thread.

protocol/osc/client.cpp

index 69f0e3ce0dcc98095f61b5ecf96f19cf19f2d750..a85cabc1e8096536d32100135737e84fea71732b 100644 (file)
@@ -154,33 +154,39 @@ public:
 
        void run()
        {
-               is_running_ = true;
+               try
+               {
+                       is_running_ = true;
 
-               std::unordered_map<std::string, byte_vector> updates;
-               std::vector<boost::asio::mutable_buffers_1>      buffers;
+                       std::unordered_map<std::string, byte_vector> updates;
+                       std::vector<boost::asio::mutable_buffers_1>      buffers;
 
-               while(true)
-               {
-                       boost::unique_lock<boost::mutex> cond_lock(cond_mutex_);
+                       while(true)
+                       {
+                               boost::unique_lock<boost::mutex> cond_lock(cond_mutex_);
                                        
-                       cond_.wait(cond_lock);
+                               cond_.wait(cond_lock);
 
-                       if(!is_running_)
-                               break;
+                               if(!is_running_)
+                                       break;
                                                        
-                       {
-                               boost::lock_guard<boost::mutex> lock(updates_mutex_);
-                               std::swap(updates, updates_);
-                       }
+                               {
+                                       boost::lock_guard<boost::mutex> lock(updates_mutex_);
+                                       std::swap(updates, updates_);
+                               }
                                                
-                       BOOST_FOREACH(auto& slot, updates)              
-                               buffers.push_back(boost::asio::buffer(slot.second));
-
-                       if(!buffers.empty())
+                               BOOST_FOREACH(auto& slot, updates)              
+                                       buffers.push_back(boost::asio::buffer(slot.second));
+                       
                                socket_.send_to(buffers, endpoint_);
                        
-                       buffers.clear();
-                       updates.clear();
+                               buffers.clear();
+                               updates.clear();
+                       }
+               }
+               catch(...)
+               {
+                       CASPAR_LOG_CURRENT_EXCEPTION();
                }
        }
 };