From: JINMEI Tatuya Date: Fri, 7 Oct 2011 23:54:55 +0000 (-0700) Subject: [1209] a related bug fix in the python datasrc wrapper: X-Git-Tag: perftcpdns_before_epoll~37^2~17^2^2~6^2~1^2~1^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=982f6e4d7e7a2ffb0d17add0df1e5643aa38c092;p=thirdparty%2Fkea.git [1209] a related bug fix in the python datasrc wrapper: DataSourceClient.get_updater must return None when it cannot find the zone. Otherwise the returned updater would be incomplete and would subseuqently cause a disruption (such as program crash). --- diff --git a/src/lib/python/isc/datasrc/client_inc.cc b/src/lib/python/isc/datasrc/client_inc.cc index 1eba4885b4..9bfedac17f 100644 --- a/src/lib/python/isc/datasrc/client_inc.cc +++ b/src/lib/python/isc/datasrc/client_inc.cc @@ -110,7 +110,7 @@ Return an updater to make updates to a specific zone.\n\ The RR class of the zone is the one that the client is expected to\n\ handle (see the detailed description of this class).\n\ \n\ -If the specified zone is not found via the client, a NULL pointer will\n\ +If the specified zone is not found via the client, a None object will\n\ be returned; in other words a completely new zone cannot be created\n\ using an updater. It must be created beforehand (even if it's an empty\n\ placeholder) in a way specific to the underlying data source.\n\ diff --git a/src/lib/python/isc/datasrc/client_python.cc b/src/lib/python/isc/datasrc/client_python.cc index c75e7caff4..8a3d408eec 100644 --- a/src/lib/python/isc/datasrc/client_python.cc +++ b/src/lib/python/isc/datasrc/client_python.cc @@ -120,9 +120,12 @@ DataSourceClient_getUpdater(PyObject* po_self, PyObject* args) { PyBool_Check(replace_obj)) { bool replace = (replace_obj != Py_False); try { - return (createZoneUpdaterObject( - self->cppobj->getUpdater(PyName_ToName(name_obj), - replace))); + ZoneUpdaterPtr updater = + self->cppobj->getUpdater(PyName_ToName(name_obj), replace); + if (!updater) { + return (Py_None); + } + return (createZoneUpdaterObject(updater)); } catch (const isc::NotImplemented& ne) { PyErr_SetString(getDataSourceException("NotImplemented"), ne.what()); diff --git a/src/lib/python/isc/datasrc/tests/datasrc_test.py b/src/lib/python/isc/datasrc/tests/datasrc_test.py index 15ceb805e7..4a7f4eab74 100644 --- a/src/lib/python/isc/datasrc/tests/datasrc_test.py +++ b/src/lib/python/isc/datasrc/tests/datasrc_test.py @@ -383,6 +383,11 @@ class DataSrcUpdater(unittest.TestCase): self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n", rrset.to_text()) + def test_update_for_no_zone(self): + dsc = isc.datasrc.DataSourceClient(WRITE_ZONE_DB_FILE) + self.assertEqual(None, + dsc.get_updater(isc.dns.Name("notexistent.example"), + True)) if __name__ == "__main__": isc.log.init("bind10")