diff -ur dhcp-4.2.0-P2-orig/dhcpctl/dhcpctl.c dhcp-4.2.0-P2/dhcpctl/dhcpctl.c --- dhcp-4.2.0-P2-orig/dhcpctl/dhcpctl.c 2009-11-20 03:49:01.000000000 +0200 +++ dhcp-4.2.0-P2/dhcpctl/dhcpctl.c 2011-02-01 17:34:34.668244000 +0200 @@ -583,6 +583,39 @@ return status; } +isc_result_t dhcpctl_handle_reference (dhcpctl_handle *h, dhcpctl_handle o, + const char *file, int line) +{ + return omapi_object_reference (h, o, file, line); +} + +isc_result_t dhcpctl_handle_dereference (dhcpctl_handle *h, + const char *file, int line) +{ + omapi_object_t *o; + omapi_protocol_object_t *p; + omapi_connection_object_t *c; + + if (!h || !*h) + return ISC_R_INVALIDARG; + o = (omapi_object_t *)(*h); + /* refcnt == 2 `cause: + * one time it is referenced as p -> inner via omapi_protocol_connect () + * and one time it is reference by h object itself + */ + if ((o -> outer != NULL) && (o -> refcnt == 2)) { + p = (omapi_protocol_object_t *)o -> outer; + if (p -> outer != NULL) { + c = (omapi_connection_object_t *)p -> outer; + + if (c -> state == omapi_connection_connected) { + omapi_disconnect (c, 1); + } + } + } + return omapi_object_dereference (h, file, line); +} + isc_result_t dhcpctl_data_string_dereference (dhcpctl_data_string *vp, const char *file, int line) { diff -ur dhcp-4.2.0-P2-orig/dhcpctl/dhcpctl.h dhcp-4.2.0-P2/dhcpctl/dhcpctl.h --- dhcp-4.2.0-P2-orig/dhcpctl/dhcpctl.h 2009-11-20 03:49:01.000000000 +0200 +++ dhcp-4.2.0-P2/dhcpctl/dhcpctl.h 2011-02-01 16:51:41.416802000 +0200 @@ -120,6 +120,10 @@ isc_result_t dhcpctl_remote_stuff_values (omapi_object_t *, omapi_object_t *, omapi_object_t *); +isc_result_t dhcpctl_handle_reference (dhcpctl_handle *, dhcpctl_handle, + const char *, int); +isc_result_t dhcpctl_handle_dereference (dhcpctl_handle *, + const char *, int); isc_result_t dhcpctl_data_string_dereference (dhcpctl_data_string *, const char *, int); #endif /* _DHCPCTL_H_ */