2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 15:45:25 +00:00

Clean up many compiler warnings.

This commit is contained in:
Michael Graff
1999-02-11 06:38:12 +00:00
parent c9978f9dce
commit 882350d11c
11 changed files with 126 additions and 101 deletions

View File

@@ -287,6 +287,10 @@ main(int argc, char *argv[])
if (want_stats) if (want_stats)
isc_mem_stats(mctx, stdout); isc_mem_stats(mctx, stdout);
/*
* XXX Need to set up a condition variable here, and wait on it.
* For now, just semi-busy loop.
*/
for (;;) for (;;)
sleep(10); sleep(10);

View File

@@ -82,7 +82,7 @@ main(int argc, char *argv[]) {
ISC_BUFFERTYPE_BINARY); ISC_BUFFERTYPE_BINARY);
dns_name_init(&oname, NULL); dns_name_init(&oname, NULL);
result = dns_name_fromtext(&oname, &source, result = dns_name_fromtext(&oname, &source,
dns_rootname, 0, dns_rootname, ISC_FALSE,
&target); &target);
if (result != 0) { if (result != 0) {
fprintf(stderr, fprintf(stderr,
@@ -107,7 +107,7 @@ main(int argc, char *argv[]) {
ISC_BUFFERTYPE_BINARY); ISC_BUFFERTYPE_BINARY);
dns_name_init(&compname, compoffsets); dns_name_init(&compname, compoffsets);
result = dns_name_fromtext(&compname, &source, result = dns_name_fromtext(&compname, &source,
origin, 0, origin, ISC_FALSE,
&target); &target);
if (result != 0) { if (result != 0) {
fprintf(stderr, fprintf(stderr,
@@ -142,7 +142,7 @@ main(int argc, char *argv[]) {
if (result == DNS_R_SUCCESS) { if (result == DNS_R_SUCCESS) {
isc_buffer_init(&source, s, sizeof s, isc_buffer_init(&source, s, sizeof s,
ISC_BUFFERTYPE_TEXT); ISC_BUFFERTYPE_TEXT);
result = dns_name_totext(&name, 0, &source); result = dns_name_totext(&name, ISC_FALSE, &source);
if (result == DNS_R_SUCCESS) { if (result == DNS_R_SUCCESS) {
isc_buffer_used(&source, &r); isc_buffer_used(&source, &r);
printf("%.*s\n", (int)r.length, r.base); printf("%.*s\n", (int)r.length, r.base);

View File

@@ -65,7 +65,8 @@ create_name(char *s) {
dns_name_init(name, NULL); dns_name_init(name, NULL);
isc_buffer_init(&target, name + 1, DNSNAMELEN, ISC_BUFFERTYPE_BINARY); isc_buffer_init(&target, name + 1, DNSNAMELEN, ISC_BUFFERTYPE_BINARY);
result = dns_name_fromtext(name, &source, dns_rootname, 0, &target); result = dns_name_fromtext(name, &source, dns_rootname,
ISC_FALSE, &target);
if (result != DNS_R_SUCCESS) { if (result != DNS_R_SUCCESS) {
printf("dns_name_fromtext(%s) failed: %s\n", printf("dns_name_fromtext(%s) failed: %s\n",
@@ -92,7 +93,7 @@ print_data(void *data) {
isc_buffer_init(&target, buffer, sizeof(buffer), ISC_BUFFERTYPE_TEXT); isc_buffer_init(&target, buffer, sizeof(buffer), ISC_BUFFERTYPE_TEXT);
dns_name_totext(data, 1, &target); dns_name_totext(data, ISC_TRUE, &target);
printf("%.*s", (int)target.used, (char *)target.base); printf("%.*s", (int)target.used, (char *)target.base);
} }

View File

@@ -259,7 +259,6 @@ main(int argc, char *argv[])
isc_time_t expires, now; isc_time_t expires, now;
isc_interval_t interval; isc_interval_t interval;
isc_timer_t *ti1 = NULL; isc_timer_t *ti1 = NULL;
isc_event_t *event;
unsigned int workers; unsigned int workers;
isc_socketmgr_t *socketmgr; isc_socketmgr_t *socketmgr;
isc_socket_t *so1, *so2; isc_socket_t *so1, *so2;
@@ -345,40 +344,6 @@ main(int argc, char *argv[])
sleep(1); sleep(1);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1",
sizeof *event);
isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "2",
sizeof *event);
isc_task_send(t2, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "2",
sizeof *event);
isc_task_send(t2, &event);
while (sockets_active > 0) { while (sockets_active > 0) {
printf("Sockets active: %d\n", sockets_active); printf("Sockets active: %d\n", sockets_active);
sleep (5); sleep (5);

View File

@@ -118,49 +118,57 @@ main(int argc, char *argv[]) {
printf("task 2 = %p\n", t2); printf("task 2 = %p\n", t2);
sleep(2); sleep(2);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", /*
* Note: (void *)1 is used as a sender here, since some compilers
* don't like casting a function pointer to a (void *).
*
* In a real use, it is more likely the sender would be a
* structure (socket, timer, task, etc) but this is just a test
* program.
*/
event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "1", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "1",
sizeof *event); sizeof *event);
isc_task_send(t1, &event); isc_task_send(t1, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "2", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "2",
sizeof *event); sizeof *event);
isc_task_send(t2, &event); isc_task_send(t2, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "3", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "3",
sizeof *event); sizeof *event);
isc_task_send(t3, &event); isc_task_send(t3, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "4", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "4",
sizeof *event); sizeof *event);
isc_task_send(t4, &event); isc_task_send(t4, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "2", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "2",
sizeof *event); sizeof *event);
isc_task_send(t2, &event); isc_task_send(t2, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "3", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "3",
sizeof *event); sizeof *event);
isc_task_send(t3, &event); isc_task_send(t3, &event);
event = isc_event_allocate(mctx, (void *)main, 1, my_callback, "4", event = isc_event_allocate(mctx, (void *)1, 1, my_callback, "4",
sizeof *event); sizeof *event);
isc_task_send(t4, &event); isc_task_send(t4, &event);
isc_task_purge(t3, NULL, 0); isc_task_purge(t3, NULL, 0);

View File

@@ -92,8 +92,10 @@ fromhex(char c) {
return (c - 'a' + 10); return (c - 'a' + 10);
else if (c >= 'A' && c <= 'F') else if (c >= 'A' && c <= 'F')
return (c - 'A' + 10); return (c - 'A' + 10);
printf("bad input format: %02x\n", c); printf("bad input format: %02x\n", c);
exit(3); exit(3);
/* NOTREACHED */
} }
static isc_uint16_t static isc_uint16_t

View File

@@ -36,8 +36,11 @@
/* Define if you have the <unistd.h> header file. */ /* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
/* Define if you have the nsl library (-lnsl). */
#undef HAVE_LIBNSL
/* Define if you have the pthread library (-lpthread). */ /* Define if you have the pthread library (-lpthread). */
#undef HAVE_LIBPTHREAD #undef HAVE_LIBPTHREAD
/* Define if you have the xnet library (-lxnet). */ /* Define if you have the socket library (-lsocket). */
#undef HAVE_LIBXNET #undef HAVE_LIBSOCKET

44
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# From configure.in Revision: 1.15 # From configure.in Revision: 1.16
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.12 # Generated automatically using autoconf version 2.12
@@ -1290,8 +1290,12 @@ fi
fi fi
case "$host" in
mips-sgi-irix*)
;;
*)
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
echo "configure:1295: checking for socket in -lsocket" >&5 echo "configure:1299: checking for socket in -lsocket" >&5
ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@@ -1299,7 +1303,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS" LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1303 "configure" #line 1307 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@@ -1310,7 +1314,7 @@ int main() {
socket() socket()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then if { (eval echo configure:1318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@@ -1338,7 +1342,7 @@ else
fi fi
echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6 echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6
echo "configure:1342: checking for inet_ntoa in -lnsl" >&5 echo "configure:1346: checking for inet_ntoa in -lnsl" >&5
ac_lib_var=`echo nsl'_'inet_ntoa | sed 'y%./+-%__p_%'` ac_lib_var=`echo nsl'_'inet_ntoa | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@@ -1346,7 +1350,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS" LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1350 "configure" #line 1354 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@@ -1357,7 +1361,7 @@ int main() {
inet_ntoa() inet_ntoa()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then if { (eval echo configure:1365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@@ -1384,14 +1388,16 @@ else
echo "$ac_t""no" 1>&6 echo "$ac_t""no" 1>&6
fi fi
;;
esac
echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6 echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
echo "configure:1390: checking for inet_ntop" >&5 echo "configure:1396: checking for inet_ntop" >&5
if eval "test \"`echo '$''{'ac_cv_func_inet_ntop'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_func_inet_ntop'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1395 "configure" #line 1401 "configure"
#include "confdefs.h" #include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes, /* System header to define __stub macros and hopefully few prototypes,
which can conflict with char inet_ntop(); below. */ which can conflict with char inet_ntop(); below. */
@@ -1414,7 +1420,7 @@ inet_ntop();
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then if { (eval echo configure:1424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest* rm -rf conftest*
eval "ac_cv_func_inet_ntop=yes" eval "ac_cv_func_inet_ntop=yes"
else else
@@ -1441,12 +1447,12 @@ EOF
fi fi
echo $ac_n "checking for inet_pton""... $ac_c" 1>&6 echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
echo "configure:1445: checking for inet_pton" >&5 echo "configure:1451: checking for inet_pton" >&5
if eval "test \"`echo '$''{'ac_cv_func_inet_pton'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_func_inet_pton'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1450 "configure" #line 1456 "configure"
#include "confdefs.h" #include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes, /* System header to define __stub macros and hopefully few prototypes,
which can conflict with char inet_pton(); below. */ which can conflict with char inet_pton(); below. */
@@ -1469,7 +1475,7 @@ inet_pton();
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then if { (eval echo configure:1479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest* rm -rf conftest*
eval "ac_cv_func_inet_pton=yes" eval "ac_cv_func_inet_pton=yes"
else else
@@ -1496,12 +1502,12 @@ EOF
fi fi
echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
echo "configure:1500: checking for inet_aton" >&5 echo "configure:1506: checking for inet_aton" >&5
if eval "test \"`echo '$''{'ac_cv_func_inet_aton'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_func_inet_aton'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1505 "configure" #line 1511 "configure"
#include "confdefs.h" #include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes, /* System header to define __stub macros and hopefully few prototypes,
which can conflict with char inet_aton(); below. */ which can conflict with char inet_aton(); below. */
@@ -1524,7 +1530,7 @@ inet_aton();
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then if { (eval echo configure:1534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest* rm -rf conftest*
eval "ac_cv_func_inet_aton=yes" eval "ac_cv_func_inet_aton=yes"
else else
@@ -1552,7 +1558,7 @@ fi
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
echo "configure:1556: checking whether ${MAKE-make} sets \${MAKE}" >&5 echo "configure:1562: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@@ -1581,7 +1587,7 @@ fi
# Extract the first word of "ranlib", so it can be a program name with args. # Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2 set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1585: checking for $ac_word" >&5 echo "configure:1591: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@@ -1618,7 +1624,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh. # ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:1622: checking for a BSD compatible install" >&5 echo "configure:1628: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6

View File

@@ -1,5 +1,5 @@
AC_REVISION($Revision: 1.16 $) AC_REVISION($Revision: 1.17 $)
AC_INIT(lib/dns/name.c) AC_INIT(lib/dns/name.c)
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
@@ -56,8 +56,14 @@ dnl )
dnl dnl
dnl Use this for now, instead: dnl Use this for now, instead:
dnl dnl
case "$host" in
mips-sgi-irix*)
;;
*)
AC_CHECK_LIB(socket, socket) AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, inet_ntoa) AC_CHECK_LIB(nsl, inet_ntoa)
;;
esac
AC_CHECK_FUNC(inet_ntop, , AC_CHECK_FUNC(inet_ntop, ,
[ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.o" [ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.o"

View File

@@ -1566,7 +1566,7 @@ dns_rbt_printnodename(dns_rbtnode_t *node) {
dns_name_fromregion(&name, &r); dns_name_fromregion(&name, &r);
isc_buffer_init(&target, buffer, 255, ISC_BUFFERTYPE_TEXT); isc_buffer_init(&target, buffer, 255, ISC_BUFFERTYPE_TEXT);
dns_name_totext(&name, 1, &target); dns_name_totext(&name, ISC_TRUE, &target);
printf("%.*s", (int)target.used, (char *)target.base); printf("%.*s", (int)target.used, (char *)target.base);
} }

View File

@@ -36,17 +36,30 @@
#include "util.h" #include "util.h"
/* temp hack! XXX */ /*
* Some systems define the socket length argument as an int, some as size_t,
* some as socklen_t. This is here, so it can be easily changed if needed.
*/
#define ISC_SOCKADDR_LEN_T int #define ISC_SOCKADDR_LEN_T int
#ifndef _WIN32 /*
#define WINAPI /* we're not windows */ * As above, one system (solaris) wants the pointers passed into recv() and
#endif * the other network functions to be char *. All the others seem to use
* void *. Cast everything to char * for now.
*/
#define ISC_SOCKDATA_CAST(x) ((char *)(x))
/*
* If we cannot send to this task, the application is broken.
*/
#define ISC_TASK_SEND(a, b) do { \ #define ISC_TASK_SEND(a, b) do { \
RUNTIME_CHECK(isc_task_send(a, b) == ISC_R_SUCCESS); \ RUNTIME_CHECK(isc_task_send(a, b) == ISC_R_SUCCESS); \
} while (0); } while (0);
/*
* Define what the possible "soft" errors can be. These are non-fatal returns
* of various network related functions, like recv() and so on.
*/
#define SOFT_ERROR(e) ((e) == EAGAIN || (e) == EWOULDBLOCK || (e) == EINTR || (e) == 0) /* XXX 0? */ #define SOFT_ERROR(e) ((e) == EAGAIN || (e) == EWOULDBLOCK || (e) == EINTR || (e) == 0) /* XXX 0? */
#if 0 #if 0
@@ -72,7 +85,7 @@ int trace_level = 0xffffffff;
#endif #endif
/* /*
* internal event used to send readable/writable events to our internal * Internal event used to send readable/writable events to our internal
* functions. * functions.
*/ */
typedef struct rwintev { typedef struct rwintev {
@@ -185,11 +198,16 @@ select_poke(isc_socketmgr_t *mgr, int msg)
{ {
int cc; int cc;
do {
cc = write(mgr->pipe_fds[1], &msg, sizeof(int)); cc = write(mgr->pipe_fds[1], &msg, sizeof(int));
if (cc < 0) /* XXX need to handle EAGAIN, EINTR here */ } while (cc < 0 && SOFT_ERROR(errno));
if (cc < 0)
FATAL_ERROR(__FILE__, __LINE__, FATAL_ERROR(__FILE__, __LINE__,
"write() failed during watcher poke: %s", "write() failed during watcher poke: %s",
strerror(errno)); strerror(errno));
INSIST(cc == sizeof(int));
} }
/* /*
@@ -482,12 +500,14 @@ isc_socket_create(isc_socketmgr_t *manager, isc_sockettype_t type,
case ENFILE: case ENFILE:
case ENOBUFS: case ENOBUFS:
return (ISC_R_NORESOURCES); return (ISC_R_NORESOURCES);
/* NOTREACHED */
break; break;
default: default:
UNEXPECTED_ERROR(__FILE__, __LINE__, UNEXPECTED_ERROR(__FILE__, __LINE__,
"socket() failed: %s", "socket() failed: %s",
strerror(errno)); strerror(errno));
return (ISC_R_UNEXPECTED); return (ISC_R_UNEXPECTED);
/* NOTREACHED */
break; break;
} }
} }
@@ -787,8 +807,6 @@ internal_accept(isc_task_t *task, isc_event_t *ev)
fd = -1; fd = -1;
result = ISC_R_UNEXPECTED; result = ISC_R_UNEXPECTED;
free_socket(&dev->newsocket);
} }
DEQUEUE(sock->accept_list, iev, link); DEQUEUE(sock->accept_list, iev, link);
@@ -902,7 +920,9 @@ internal_recv(isc_task_t *task, isc_event_t *ev)
read_count = dev->region.length - dev->n; read_count = dev->region.length - dev->n;
if (sock->type == isc_socket_udp) { if (sock->type == isc_socket_udp) {
addrlen = sizeof(addr); addrlen = sizeof(addr);
cc = recvfrom(sock->fd, dev->region.base + dev->n, cc = recvfrom(sock->fd,
ISC_SOCKDATA_CAST(dev->region.base
+ dev->n),
read_count, 0, read_count, 0,
(struct sockaddr *)&addr, (struct sockaddr *)&addr,
&addrlen); &addrlen);
@@ -911,7 +931,8 @@ internal_recv(isc_task_t *task, isc_event_t *ev)
dev->addrlength = addrlen; dev->addrlength = addrlen;
} }
} else { } else {
cc = recv(sock->fd, dev->region.base + dev->n, cc = recv(sock->fd,
ISC_SOCKDATA_CAST(dev->region.base + dev->n),
read_count, 0); read_count, 0);
if (cc >= 0) { if (cc >= 0) {
memcpy(&dev->address, &sock->address, memcpy(&dev->address, &sock->address,
@@ -1090,13 +1111,16 @@ internal_send(isc_task_t *task, isc_event_t *ev)
*/ */
write_count = dev->region.length - dev->n; write_count = dev->region.length - dev->n;
if (sock->type == isc_socket_udp) if (sock->type == isc_socket_udp)
cc = sendto(sock->fd, dev->region.base + dev->n, cc = sendto(sock->fd,
ISC_SOCKDATA_CAST(dev->region.base
+ dev->n),
write_count, 0, write_count, 0,
(struct sockaddr *)&dev->address, (struct sockaddr *)&dev->address,
(int)dev->addrlength); (int)dev->addrlength);
else else
cc = send(sock->fd, dev->region.base + dev->n, cc = send(sock->fd,
ISC_SOCKDATA_CAST(dev->region.base + dev->n),
write_count, 0); write_count, 0);
/* /*
@@ -1194,7 +1218,6 @@ internal_send(isc_task_t *task, isc_event_t *ev)
* this I/O and post the event to it. * this I/O and post the event to it.
*/ */
static isc_threadresult_t static isc_threadresult_t
WINAPI
watcher(void *uap) watcher(void *uap)
{ {
isc_socketmgr_t *manager = uap; isc_socketmgr_t *manager = uap;
@@ -1640,13 +1663,14 @@ isc_socket_recv(isc_socket_t *sock, isc_region_t *region,
ISC_SOCKADDR_LEN_T addrlen; ISC_SOCKADDR_LEN_T addrlen;
ev->addrlength = sizeof(isc_sockaddr_t); ev->addrlength = sizeof(isc_sockaddr_t);
addrlen = (ISC_SOCKADDR_LEN_T)ev->addrlength; addrlen = (ISC_SOCKADDR_LEN_T)ev->addrlength;
cc = recvfrom(sock->fd, ev->region.base, cc = recvfrom(sock->fd,
ISC_SOCKDATA_CAST(ev->region.base),
ev->region.length, 0, ev->region.length, 0,
(struct sockaddr *)&ev->address, (struct sockaddr *)&ev->address,
&addrlen); &addrlen);
ev->addrlength = (unsigned int)addrlen; ev->addrlength = (unsigned int)addrlen;
} else { } else {
cc = recv(sock->fd, ev->region.base, cc = recv(sock->fd, ISC_SOCKDATA_CAST(ev->region.base),
ev->region.length, 0); ev->region.length, 0);
ev->address = sock->address; ev->address = sock->address;
ev->addrlength = sock->addrlength; ev->addrlength = sock->addrlength;
@@ -1814,12 +1838,13 @@ isc_socket_sendto(isc_socket_t *sock, isc_region_t *region,
if (EMPTY(sock->send_list)) { if (EMPTY(sock->send_list)) {
if (sock->type == isc_socket_udp) if (sock->type == isc_socket_udp)
cc = sendto(sock->fd, ev->region.base, cc = sendto(sock->fd,
ISC_SOCKDATA_CAST(ev->region.base),
ev->region.length, 0, ev->region.length, 0,
(struct sockaddr *)&ev->address, (struct sockaddr *)&ev->address,
(int)ev->addrlength); (int)ev->addrlength);
else if (sock->type == isc_socket_tcp) else if (sock->type == isc_socket_tcp)
cc = send(sock->fd, ev->region.base, cc = send(sock->fd, ISC_SOCKDATA_CAST(ev->region.base),
ev->region.length, 0); ev->region.length, 0);
else { else {
UNEXPECTED_ERROR(__FILE__, __LINE__, UNEXPECTED_ERROR(__FILE__, __LINE__,
@@ -1912,7 +1937,7 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr,
LOCK(&sock->lock); LOCK(&sock->lock);
if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR,
&on, sizeof on) < 0) { ISC_SOCKDATA_CAST(&on), sizeof on) < 0) {
UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d) failed", UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d) failed",
sock->fd); sock->fd);
/* Press on... */ /* Press on... */
@@ -1922,20 +1947,25 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr,
switch (errno) { switch (errno) {
case EACCES: case EACCES:
return (ISC_R_NOPERM); return (ISC_R_NOPERM);
/* NOTREACHED */
break; break;
case EADDRNOTAVAIL: case EADDRNOTAVAIL:
return (ISC_R_ADDRNOTAVAIL); return (ISC_R_ADDRNOTAVAIL);
/* NOTREACHED */
break; break;
case EADDRINUSE: case EADDRINUSE:
return (ISC_R_ADDRINUSE); return (ISC_R_ADDRINUSE);
/* NOTREACHED */
break; break;
case EINVAL: case EINVAL:
return (ISC_R_BOUND); return (ISC_R_BOUND);
/* NOTREACHED */
break; break;
default: default:
UNEXPECTED_ERROR(__FILE__, __LINE__, UNEXPECTED_ERROR(__FILE__, __LINE__,
"bind: %s", strerror(errno)); "bind: %s", strerror(errno));
return (ISC_R_UNEXPECTED); return (ISC_R_UNEXPECTED);
/* NOTREACHED */
break; break;
} }
} }