It is currently Fri Dec 13, 2019 9:29 am


All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [PATCH] Patch for qemuwrapper.py - Broken Pipe
PostPosted: Sun Nov 18, 2012 5:01 pm 
Offline

Joined: Sun Nov 04, 2012 8:11 pm
Posts: 19
Location: Buenos Aires, Argentina
Hi!. When exit from Dynagen in console mode, the qemuwrapper.py launch a exception: [Errno 32] Broken pipe

This patch prevent this. It is only decorative, make the text in the qemuwrapper console more easy to read.

Code:
diff -r -u proposal/GNS3-0.8.3.1-src/qemuwrapper/qemuwrapper.py testing/GNS3-0.8.3.1-src/qemuwrapper/qemuwrapper.py
--- proposal/GNS3-0.8.3.1-src/qemuwrapper/qemuwrapper.py   2012-11-17 00:39:16.618998040 -0300
+++ testing/GNS3-0.8.3.1-src/qemuwrapper/qemuwrapper.py   2012-11-18 13:14:21.621205858 -0300
@@ -691,6 +691,7 @@
             self.handle_one_request()
             while not self.close_connection:
                 self.handle_one_request()
+            print "Disconnection from", self.client_address
         except socket.error, e:
             print >> sys.stderr, e
             self.request.close()
@@ -706,6 +707,9 @@
             pass
         return tokens

+    def finish(self):
+        pass
+
     def handle_one_request(self):
         debugmsg(3, "QemuWrapperRequestHandler::handle_one_request()")
         request = self.rfile.readline()
@@ -719,8 +723,11 @@
         # Parse request.
         tokens = self.__get_tokens(request)
         if len(tokens) < 2:
-            self.send_reply(self.HSC_ERR_PARSING, 1,
-                            "At least a module and a command must be specified")
+            try:
+                self.send_reply(self.HSC_ERR_PARSING, 1,
+                                "At least a module and a command must be specified")
+            except socket.error:
+                self.close_connection = 1
             return

         module, command = tokens[:2]


I'm not a expert python programmer, I don't know why this works, specially the 'finish()' overloaded empty method, but works for me.

Tested in Ubuntu 12.10 with Python 2.7.3 and Ubuntu 10.10 with Python 2.6.6.




Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

phpBB SEO