[svn] commit: r1937 - /branches/feng-authnotify/src/bin/auth/main.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 26 10:48:00 UTC 2010


Author: hanfeng
Date: Wed May 26 10:48:00 2010
New Revision: 1937

Log:
add exception handling when parse notify query

Modified:
    branches/feng-authnotify/src/bin/auth/main.cc

Modified: branches/feng-authnotify/src/bin/auth/main.cc
==============================================================================
--- branches/feng-authnotify/src/bin/auth/main.cc (original)
+++ branches/feng-authnotify/src/bin/auth/main.cc Wed May 26 10:48:00 2010
@@ -157,27 +157,33 @@
         return;
     //get updated zone name and remote master's ip address and send to xfrin module
     InputBuffer name_buffer(data + MIN_NOTIFY_HEAD_LEN, data_len - MIN_NOTIFY_HEAD_LEN);
-    Name name(name_buffer);
-    //TODO check with the conf-mgr whether current server is the auth of the zone
-    Session tmp_session_with_xfr;
-    tmp_session_with_xfr.establish();
-    const string remote_ip_address = sender.address().to_string();
-    ElementPtr notify_command = Element::createFromString("{\"command\": [\"notify\", {\"zone_name\" : \""
+    try
+    {
+        Name name(name_buffer);
+        //TODO check with the conf-mgr whether current server is the auth of the zone
+        Session tmp_session_with_xfr;
+        tmp_session_with_xfr.establish();
+        const string remote_ip_address = sender.address().to_string();
+        ElementPtr notify_command = Element::createFromString("{\"command\": [\"notify\", {\"zone_name\" : \""
                                                             + name.toText() 
                                                             + "\", \"master_ip\" : \""
                                                             + remote_ip_address
                                                             + "\"}]}");
-    unsigned int seq = tmp_session_with_xfr.group_sendmsg(notify_command, "Xfrin");
-    ElementPtr env, answer;
-    tmp_session_with_xfr.group_recvmsg(env, answer, false, seq);
-    int rcode;
-    cerr << "++++++++before parese answer\n";
-    ElementPtr err = parseAnswer(rcode, answer);
-    if (rcode != 0) 
+        unsigned int seq = tmp_session_with_xfr.group_sendmsg(notify_command, "Xfrin");
+        ElementPtr env, answer;
+        tmp_session_with_xfr.group_recvmsg(env, answer, false, seq);
+        int rcode;
+        ElementPtr err = parseAnswer(rcode, answer);
+        if (rcode != 0) 
+        {
+            cerr << "notify send failed" << std::endl;
+        }
+    } 
+    catch (const std::exception& ex) 
     {
-        std::cerr << "notify send failed" << std::endl;
-    }
-    cerr << "++++++++after parese answer\n";
+        cerr << "error handle notify query:" << ex.what() << endl;
+    }
+    
     //set the qr bit
     uint8_t *qr_start_byte = data + 2;
     *qr_start_byte |= 0x80;




More information about the bind10-changes mailing list