@@ -112,6 +112,36 @@ context_set_timeout(getdns_context *context, PyObject *py_value)
112112}
113113
114114
115+ int
116+ context_set_idle_timeout (getdns_context * context , PyObject * py_value )
117+ {
118+ getdns_return_t ret ;
119+ uint64_t value ;
120+
121+ #if PY_MAJOR_VERSION >= 3
122+ if (!PyLong_Check (py_value )) {
123+ #else
124+ if (!PyInt_Check (py_value )) {
125+ #endif
126+ PyErr_SetString (getdns_error , GETDNS_RETURN_INVALID_PARAMETER_TEXT );
127+ return -1 ;
128+ }
129+ #if PY_MAJOR_VERSION >= 3
130+ if ((long )(value = PyLong_AsLong (py_value )) < 0 ) {
131+ #else
132+ if ((long )(value = PyInt_AsLong (py_value )) < 0 ) {
133+ #endif
134+ PyErr_SetString (getdns_error , GETDNS_RETURN_INVALID_PARAMETER_TEXT );
135+ return -1 ;
136+ }
137+ if ((ret = getdns_context_set_idle_timeout (context , value )) != GETDNS_RETURN_GOOD ) {
138+ PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
139+ return -1 ;
140+ }
141+ return 0 ;
142+ }
143+
144+
115145int
116146context_set_resolution_type (getdns_context * context , PyObject * py_value )
117147{
@@ -830,6 +860,14 @@ context_getattro(PyObject *self, PyObject *nameobj)
830860 }
831861 return PyLong_FromLong ((long )timeout );
832862 }
863+ if (!strncmp (attrname , "idle_timeout" , strlen ("idle_timeout" ))) {
864+ uint64_t timeout ;
865+ if ((ret = getdns_context_get_idle_timeout (context , & timeout )) != GETDNS_RETURN_GOOD ) {
866+ PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
867+ return NULL ;
868+ }
869+ return PyLong_FromLong ((long )timeout );
870+ }
833871 if (!strncmp (attrname , "dns_transport_list" , strlen ("dns_transport_list" ))) {
834872 getdns_transport_list_t * transports ;
835873 PyObject * py_transports ;
@@ -1055,6 +1093,9 @@ context_setattro(PyObject *self, PyObject *attrname, PyObject *py_value)
10551093 if (!strncmp (name , "timeout" , strlen ("timeout" ))) {
10561094 return (context_set_timeout (context , py_value ));
10571095 }
1096+ if (!strncmp (name , "idle_timeout" , strlen ("idle_timeout" ))) {
1097+ return (context_set_idle_timeout (context , py_value ));
1098+ }
10581099 if (!strncmp (name , "resolution_type" , strlen ("resolution_type" ))) {
10591100 return (context_set_resolution_type (context , py_value ));
10601101 }
0 commit comments