PERFORCE change 95781 for review
soc-bushman
soc-bushman at FreeBSD.org
Fri Apr 21 08:25:41 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=95781
Change 95781 by soc-bushman at soc-bushman_stinger on 2006/04/21 08:24:42
all hosts-related functions now take resolver options into account
Affected files ...
.. //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/getaddrinfo.c#11 edit
.. //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/gethostnamadr.c#8 edit
.. //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/name6.c#10 edit
.. //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/nscachedcli.c#10 edit
Differences ...
==== //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/getaddrinfo.c#11 (text+ko) ====
@@ -1537,6 +1537,9 @@
addrinfo_id_func(char *buffer, size_t *buffer_size, va_list ap,
void *cache_mdata)
{
+ res_state statp;
+ u_long res_options;
+
const int op_id = 0; /* identifies the getaddrinfo for the cache */
char *hostname;
struct addrinfo *hints;
@@ -1545,10 +1548,14 @@
int ai_flags, ai_family, ai_socktype, ai_protocol;
size_t desired_size, size;
+ statp = __res_state();
+ res_options = statp->options & (RES_RECURSE | RES_DEFNAMES |
+ RES_DNSRCH | RES_NOALIASES | RES_USE_INET6);
+
hostname = va_arg(ap, char *);
hints = va_arg(ap, struct addrinfo *);
- desired_size = sizeof(int) + sizeof(int) * 4;
+ desired_size = sizeof(res_options) + sizeof(int) + sizeof(int) * 4;
if (hostname != NULL) {
size = strlen(hostname);
desired_size += size + 1;
@@ -1570,6 +1577,9 @@
}
p = buffer;
+ memcpy(p, &res_options, sizeof(res_options));
+ p += sizeof(res_options);
+
memcpy(p, &op_id, sizeof(int));
p += sizeof(int);
==== //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/gethostnamadr.c#8 (text+ko) ====
@@ -162,6 +162,9 @@
static int
host_id_func(char *buffer, size_t *buffer_size, va_list ap, void *cache_mdata)
{
+ res_state statp;
+ u_long res_options;
+
const int op_id = 1;
char *str;
int len, type;
@@ -170,10 +173,11 @@
enum nss_lookup_type lookup_type;
char *p;
int res = NS_UNAVAIL;
-
- res_state statp;
+
+ statp = __res_state();
+ res_options = statp->options & (RES_RECURSE | RES_DEFNAMES |
+ RES_DNSRCH | RES_NOALIASES | RES_USE_INET6);
- stat_p = __res_state();
lookup_type = (enum nss_lookup_type)cache_mdata;
switch (lookup_type) {
case nss_lt_name:
@@ -181,7 +185,7 @@
type = va_arg(ap, int);
size = strlen(str);
- desired_size = sizeof(stat_p->options) + sizeof(int) +
+ desired_size = sizeof(res_options) + sizeof(int) +
sizeof(enum nss_lookup_type) + sizeof(int) + size + 1;
if (desired_size > *buffer_size) {
@@ -191,8 +195,8 @@
p = buffer;
- memcpy(p, &stat_p->options, sizeof(stat_p->options));
- p += sizeof(stat_p->options);
+ memcpy(p, &res_options, sizeof(res_options));
+ p += sizeof(res_options);
memcpy(p, &op_id, sizeof(int));
p += sizeof(int);
@@ -212,8 +216,8 @@
len = va_arg(ap, int);
type = va_arg(ap, int);
- desired_size = sizeof(int) + sizeof(enum nss_lookup_type) +
- + sizeof(int) * 2 + len;
+ desired_size = sizeof(res_options) + sizeof(int) +
+ sizeof(enum nss_lookup_type) + sizeof(int) * 2 + len;
if (desired_size > *buffer_size) {
res = NS_RETURN;
@@ -221,6 +225,9 @@
}
p = buffer;
+ memcpy(p, &res_options, sizeof(res_options));
+ p += sizeof(res_options);
+
memcpy(p, &op_id, sizeof(int));
p += sizeof(int);
==== //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/name6.c#10 (text+ko) ====
@@ -291,6 +291,9 @@
static int
ipnode_id_func(char *buffer, size_t *buffer_size, va_list ap, void *cache_mdata)
{
+ res_state statp;
+ u_long res_options;
+
const int op_id = 2;
char *name;
int af;
@@ -302,6 +305,10 @@
enum nss_lookup_type lookup_type;
int res = NS_UNAVAIL;
+ statp = __res_state();
+ res_options = statp->options & (RES_RECURSE | RES_DEFNAMES |
+ RES_DNSRCH | RES_NOALIASES | RES_USE_INET6);
+
lookup_type = (enum nss_lookup_type)cache_mdata;
switch (lookup_type) {
case nss_lt_name:
@@ -309,8 +316,8 @@
af = va_arg(ap, int);
size = strlen(name);
- desired_size = sizeof(int) + sizeof(enum nss_lookup_type) +
- sizeof(int) + size + 1;
+ desired_size = sizeof(res_options) + sizeof(int) +
+ sizeof(enum nss_lookup_type) + sizeof(int) + size + 1;
if (desired_size > *buffer_size) {
res = NS_RETURN;
@@ -318,6 +325,9 @@
}
p = buffer;
+ memcpy(p, &res_options, sizeof(res_options));
+ p += sizeof(res_options);
+
memcpy(p, &op_id, sizeof(int));
p += sizeof(int);
@@ -336,8 +346,9 @@
len = va_arg(ap, size_t);
af = va_arg(ap, int);
- desired_size = sizeof(int) + sizeof(enum nss_lookup_type) +
- sizeof(int) + sizeof(size_t) + len;
+ desired_size = sizeof(res_options) + sizeof(int) +
+ sizeof(enum nss_lookup_type) + sizeof(int) +
+ sizeof(size_t) + len;
if (desired_size > *buffer_size) {
res = NS_RETURN;
@@ -345,6 +356,9 @@
}
p = buffer;
+ memcpy(p, &res_options, sizeof(res_options));
+ p += sizeof(res_options);
+
memcpy(p, &op_id, sizeof(int));
p += sizeof(int);
==== //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/nscachedcli.c#10 (text+ko) ====
@@ -72,7 +72,7 @@
nevents = kevent(connection->write_queue, NULL, 0, &eventlist,
1, &timeout);
if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) {
- s_result = write(connection->sockfd, data + result,
+ s_result = _write(connection->sockfd, data + result,
eventlist.data < data_size - result ?
eventlist.data : data_size - result);
if (s_result == -1)
@@ -114,7 +114,7 @@
nevents = kevent(connection->read_queue, NULL, 0, &eventlist, 1,
&timeout);
if ((nevents == 1) && (eventlist.filter == EVFILT_READ)) {
- s_result = read(connection->sockfd, data + result,
+ s_result = _read(connection->sockfd, data + result,
eventlist.data <= data_size - result ? eventlist.data :
data_size - result);
if (s_result == -1)
@@ -171,7 +171,7 @@
nevents = kevent(connection->write_queue, NULL, 0, &eventlist, 1, NULL);
if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) {
- result = (sendmsg(connection->sockfd, &cred_hdr, 0) == -1) ? -1
+ result = (_sendmsg(connection->sockfd, &cred_hdr, 0) == -1) ? -1
: 0;
EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
0, 0, NULL);
@@ -195,20 +195,20 @@
assert(params != NULL);
- client_socket = socket(PF_LOCAL, SOCK_STREAM, 0);
+ client_socket = _socket(PF_LOCAL, SOCK_STREAM, 0);
client_address.sun_family = PF_LOCAL;
strncpy(client_address.sun_path, params->socket_path,
sizeof(client_address.sun_path));
client_address_len = sizeof(client_address.sun_family) +
strlen(client_address.sun_path) + 1;
- res = connect(client_socket, (struct sockaddr *)&client_address,
+ res = _connect(client_socket, (struct sockaddr *)&client_address,
client_address_len);
if (res == -1) {
- close(client_socket);
+ _close(client_socket);
return (NULL);
}
- fcntl(client_socket, F_SETFL, O_NONBLOCK);
+ _fcntl(client_socket, F_SETFL, O_NONBLOCK);
retval = malloc(sizeof(struct cached_connection_));
assert(retval != NULL);
@@ -238,9 +238,9 @@
{
assert(connection != NULL);
- close(connection->sockfd);
- close(connection->read_queue);
- close(connection->write_queue);
+ _close(connection->sockfd);
+ _close(connection->read_queue);
+ _close(connection->write_queue);
free(connection);
}
More information about the p4-projects
mailing list