mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-02 07:15:44 +00:00
- Set the SO_REUSEADDR flag when creating sockets.
- Fix an uninitialized pointer bug.
This commit is contained in:
@@ -30,6 +30,7 @@ isc_result_t omapi_connect (omapi_object_t *c,
|
|||||||
int hix;
|
int hix;
|
||||||
isc_result_t status;
|
isc_result_t status;
|
||||||
omapi_connection_object_t *obj;
|
omapi_connection_object_t *obj;
|
||||||
|
int flag;
|
||||||
|
|
||||||
obj = (omapi_connection_object_t *)malloc (sizeof *obj);
|
obj = (omapi_connection_object_t *)malloc (sizeof *obj);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
@@ -90,6 +91,15 @@ isc_result_t omapi_connect (omapi_object_t *c,
|
|||||||
return ISC_R_UNEXPECTED;
|
return ISC_R_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the SO_REUSEADDR flag (this should not fail). */
|
||||||
|
flag = 1;
|
||||||
|
if (setsockopt (obj -> socket, SOL_SOCKET, SO_REUSEADDR,
|
||||||
|
(char *)&flag, sizeof flag) < 0) {
|
||||||
|
omapi_object_dereference ((omapi_object_t **)&obj,
|
||||||
|
"omapi_connect");
|
||||||
|
return ISC_R_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
/* Try to connect to the one IP address we were given, or any of
|
/* Try to connect to the one IP address we were given, or any of
|
||||||
the IP addresses listed in the host's A RR. */
|
the IP addresses listed in the host's A RR. */
|
||||||
while (connect (obj -> socket,
|
while (connect (obj -> socket,
|
||||||
@@ -225,6 +235,7 @@ int omapi_connection_writefd (omapi_object_t *h)
|
|||||||
omapi_connection_object_t *c;
|
omapi_connection_object_t *c;
|
||||||
if (h -> type != omapi_type_connection)
|
if (h -> type != omapi_type_connection)
|
||||||
return -1;
|
return -1;
|
||||||
|
c = (omapi_connection_object_t *)h;
|
||||||
if (c -> out_bytes)
|
if (c -> out_bytes)
|
||||||
return c -> socket;
|
return c -> socket;
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user