@@ -112,6 +112,36 @@ context_set_timeout(getdns_context *context, PyObject *py_value)
112
112
}
113
113
114
114
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
+
115
145
int
116
146
context_set_resolution_type (getdns_context * context , PyObject * py_value )
117
147
{
@@ -830,6 +860,14 @@ context_getattro(PyObject *self, PyObject *nameobj)
830
860
}
831
861
return PyLong_FromLong ((long )timeout );
832
862
}
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
+ }
833
871
if (!strncmp (attrname , "dns_transport_list" , strlen ("dns_transport_list" ))) {
834
872
getdns_transport_list_t * transports ;
835
873
PyObject * py_transports ;
@@ -1055,6 +1093,9 @@ context_setattro(PyObject *self, PyObject *attrname, PyObject *py_value)
1055
1093
if (!strncmp (name , "timeout" , strlen ("timeout" ))) {
1056
1094
return (context_set_timeout (context , py_value ));
1057
1095
}
1096
+ if (!strncmp (name , "idle_timeout" , strlen ("idle_timeout" ))) {
1097
+ return (context_set_idle_timeout (context , py_value ));
1098
+ }
1058
1099
if (!strncmp (name , "resolution_type" , strlen ("resolution_type" ))) {
1059
1100
return (context_set_resolution_type (context , py_value ));
1060
1101
}
0 commit comments