mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 23:55:27 +00:00
Clean up many compiler warnings.
This commit is contained in:
@@ -287,6 +287,10 @@ main(int argc, char *argv[])
|
||||
if (want_stats)
|
||||
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 (;;)
|
||||
sleep(10);
|
||||
|
||||
|
@@ -82,7 +82,7 @@ main(int argc, char *argv[]) {
|
||||
ISC_BUFFERTYPE_BINARY);
|
||||
dns_name_init(&oname, NULL);
|
||||
result = dns_name_fromtext(&oname, &source,
|
||||
dns_rootname, 0,
|
||||
dns_rootname, ISC_FALSE,
|
||||
&target);
|
||||
if (result != 0) {
|
||||
fprintf(stderr,
|
||||
@@ -107,7 +107,7 @@ main(int argc, char *argv[]) {
|
||||
ISC_BUFFERTYPE_BINARY);
|
||||
dns_name_init(&compname, compoffsets);
|
||||
result = dns_name_fromtext(&compname, &source,
|
||||
origin, 0,
|
||||
origin, ISC_FALSE,
|
||||
&target);
|
||||
if (result != 0) {
|
||||
fprintf(stderr,
|
||||
@@ -142,7 +142,7 @@ main(int argc, char *argv[]) {
|
||||
if (result == DNS_R_SUCCESS) {
|
||||
isc_buffer_init(&source, s, sizeof s,
|
||||
ISC_BUFFERTYPE_TEXT);
|
||||
result = dns_name_totext(&name, 0, &source);
|
||||
result = dns_name_totext(&name, ISC_FALSE, &source);
|
||||
if (result == DNS_R_SUCCESS) {
|
||||
isc_buffer_used(&source, &r);
|
||||
printf("%.*s\n", (int)r.length, r.base);
|
||||
|
@@ -65,7 +65,8 @@ create_name(char *s) {
|
||||
dns_name_init(name, NULL);
|
||||
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) {
|
||||
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);
|
||||
|
||||
dns_name_totext(data, 1, &target);
|
||||
dns_name_totext(data, ISC_TRUE, &target);
|
||||
|
||||
printf("%.*s", (int)target.used, (char *)target.base);
|
||||
}
|
||||
|
@@ -259,7 +259,6 @@ main(int argc, char *argv[])
|
||||
isc_time_t expires, now;
|
||||
isc_interval_t interval;
|
||||
isc_timer_t *ti1 = NULL;
|
||||
isc_event_t *event;
|
||||
unsigned int workers;
|
||||
isc_socketmgr_t *socketmgr;
|
||||
isc_socket_t *so1, *so2;
|
||||
@@ -345,40 +344,6 @@ main(int argc, char *argv[])
|
||||
|
||||
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) {
|
||||
printf("Sockets active: %d\n", sockets_active);
|
||||
sleep (5);
|
||||
|
@@ -118,49 +118,57 @@ main(int argc, char *argv[]) {
|
||||
printf("task 2 = %p\n", t2);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
isc_task_send(t4, &event);
|
||||
isc_task_purge(t3, NULL, 0);
|
||||
|
@@ -92,8 +92,10 @@ fromhex(char c) {
|
||||
return (c - 'a' + 10);
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
return (c - 'A' + 10);
|
||||
|
||||
printf("bad input format: %02x\n", c);
|
||||
exit(3);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static isc_uint16_t
|
||||
|
@@ -36,8 +36,11 @@
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the nsl library (-lnsl). */
|
||||
#undef HAVE_LIBNSL
|
||||
|
||||
/* Define if you have the pthread library (-lpthread). */
|
||||
#undef HAVE_LIBPTHREAD
|
||||
|
||||
/* Define if you have the xnet library (-lxnet). */
|
||||
#undef HAVE_LIBXNET
|
||||
/* Define if you have the socket library (-lsocket). */
|
||||
#undef HAVE_LIBSOCKET
|
||||
|
48
configure
vendored
48
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# From configure.in Revision: 1.15
|
||||
# From configure.in Revision: 1.16
|
||||
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated automatically using autoconf version 2.12
|
||||
@@ -1290,8 +1290,12 @@ fi
|
||||
fi
|
||||
|
||||
|
||||
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
|
||||
echo "configure:1295: checking for socket in -lsocket" >&5
|
||||
case "$host" in
|
||||
mips-sgi-irix*)
|
||||
;;
|
||||
*)
|
||||
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
|
||||
echo "configure:1299: checking for socket in -lsocket" >&5
|
||||
ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -1299,7 +1303,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lsocket $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1303 "configure"
|
||||
#line 1307 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@@ -1310,7 +1314,7 @@ int main() {
|
||||
socket()
|
||||
; return 0; }
|
||||
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*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
@@ -1337,8 +1341,8 @@ else
|
||||
echo "$ac_t""no" 1>&6
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6
|
||||
echo "configure:1342: checking for inet_ntoa in -lnsl" >&5
|
||||
echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6
|
||||
echo "configure:1346: checking for inet_ntoa in -lnsl" >&5
|
||||
ac_lib_var=`echo nsl'_'inet_ntoa | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -1346,7 +1350,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lnsl $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1350 "configure"
|
||||
#line 1354 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@@ -1357,7 +1361,7 @@ int main() {
|
||||
inet_ntoa()
|
||||
; return 0; }
|
||||
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*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
@@ -1384,14 +1388,16 @@ else
|
||||
echo "$ac_t""no" 1>&6
|
||||
fi
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
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
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1395 "configure"
|
||||
#line 1401 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char inet_ntop(); below. */
|
||||
@@ -1414,7 +1420,7 @@ inet_ntop();
|
||||
|
||||
; return 0; }
|
||||
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*
|
||||
eval "ac_cv_func_inet_ntop=yes"
|
||||
else
|
||||
@@ -1441,12 +1447,12 @@ EOF
|
||||
fi
|
||||
|
||||
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
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1450 "configure"
|
||||
#line 1456 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char inet_pton(); below. */
|
||||
@@ -1469,7 +1475,7 @@ inet_pton();
|
||||
|
||||
; return 0; }
|
||||
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*
|
||||
eval "ac_cv_func_inet_pton=yes"
|
||||
else
|
||||
@@ -1496,12 +1502,12 @@ EOF
|
||||
fi
|
||||
|
||||
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
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1505 "configure"
|
||||
#line 1511 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char inet_aton(); below. */
|
||||
@@ -1524,7 +1530,7 @@ inet_aton();
|
||||
|
||||
; return 0; }
|
||||
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*
|
||||
eval "ac_cv_func_inet_aton=yes"
|
||||
else
|
||||
@@ -1552,7 +1558,7 @@ fi
|
||||
|
||||
|
||||
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_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
|
||||
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.
|
||||
set dummy ranlib; ac_word=$2
|
||||
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
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1618,7 +1624,7 @@ fi
|
||||
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
||||
# ./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 "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 eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
|
12
configure.in
12
configure.in
@@ -1,5 +1,5 @@
|
||||
|
||||
AC_REVISION($Revision: 1.16 $)
|
||||
AC_REVISION($Revision: 1.17 $)
|
||||
|
||||
AC_INIT(lib/dns/name.c)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
@@ -56,8 +56,14 @@ dnl )
|
||||
dnl
|
||||
dnl Use this for now, instead:
|
||||
dnl
|
||||
AC_CHECK_LIB(socket, socket)
|
||||
AC_CHECK_LIB(nsl, inet_ntoa)
|
||||
case "$host" in
|
||||
mips-sgi-irix*)
|
||||
;;
|
||||
*)
|
||||
AC_CHECK_LIB(socket, socket)
|
||||
AC_CHECK_LIB(nsl, inet_ntoa)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_CHECK_FUNC(inet_ntop, ,
|
||||
[ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.o"
|
||||
|
@@ -1566,7 +1566,7 @@ dns_rbt_printnodename(dns_rbtnode_t *node) {
|
||||
dns_name_fromregion(&name, &r);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@@ -36,17 +36,30 @@
|
||||
|
||||
#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
|
||||
|
||||
#ifndef _WIN32
|
||||
#define WINAPI /* we're not windows */
|
||||
#endif
|
||||
/*
|
||||
* As above, one system (solaris) wants the pointers passed into recv() and
|
||||
* 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 { \
|
||||
RUNTIME_CHECK(isc_task_send(a, b) == ISC_R_SUCCESS); \
|
||||
} 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? */
|
||||
|
||||
#if 0
|
||||
@@ -72,7 +85,7 @@ int trace_level = 0xffffffff;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* internal event used to send readable/writable events to our internal
|
||||
* Internal event used to send readable/writable events to our internal
|
||||
* functions.
|
||||
*/
|
||||
typedef struct rwintev {
|
||||
@@ -185,11 +198,16 @@ select_poke(isc_socketmgr_t *mgr, int msg)
|
||||
{
|
||||
int cc;
|
||||
|
||||
do {
|
||||
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__,
|
||||
"write() failed during watcher poke: %s",
|
||||
strerror(errno));
|
||||
|
||||
INSIST(cc == sizeof(int));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -482,12 +500,14 @@ isc_socket_create(isc_socketmgr_t *manager, isc_sockettype_t type,
|
||||
case ENFILE:
|
||||
case ENOBUFS:
|
||||
return (ISC_R_NORESOURCES);
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() failed: %s",
|
||||
strerror(errno));
|
||||
return (ISC_R_UNEXPECTED);
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -787,8 +807,6 @@ internal_accept(isc_task_t *task, isc_event_t *ev)
|
||||
fd = -1;
|
||||
|
||||
result = ISC_R_UNEXPECTED;
|
||||
|
||||
free_socket(&dev->newsocket);
|
||||
}
|
||||
|
||||
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;
|
||||
if (sock->type == isc_socket_udp) {
|
||||
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,
|
||||
(struct sockaddr *)&addr,
|
||||
&addrlen);
|
||||
@@ -911,7 +931,8 @@ internal_recv(isc_task_t *task, isc_event_t *ev)
|
||||
dev->addrlength = addrlen;
|
||||
}
|
||||
} 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);
|
||||
if (cc >= 0) {
|
||||
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;
|
||||
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,
|
||||
(struct sockaddr *)&dev->address,
|
||||
(int)dev->addrlength);
|
||||
|
||||
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);
|
||||
|
||||
/*
|
||||
@@ -1194,7 +1218,6 @@ internal_send(isc_task_t *task, isc_event_t *ev)
|
||||
* this I/O and post the event to it.
|
||||
*/
|
||||
static isc_threadresult_t
|
||||
WINAPI
|
||||
watcher(void *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;
|
||||
ev->addrlength = sizeof(isc_sockaddr_t);
|
||||
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,
|
||||
(struct sockaddr *)&ev->address,
|
||||
&addrlen);
|
||||
ev->addrlength = (unsigned int)addrlen;
|
||||
} else {
|
||||
cc = recv(sock->fd, ev->region.base,
|
||||
cc = recv(sock->fd, ISC_SOCKDATA_CAST(ev->region.base),
|
||||
ev->region.length, 0);
|
||||
ev->address = sock->address;
|
||||
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 (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,
|
||||
(struct sockaddr *)&ev->address,
|
||||
(int)ev->addrlength);
|
||||
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);
|
||||
else {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
@@ -1912,7 +1937,7 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr,
|
||||
LOCK(&sock->lock);
|
||||
|
||||
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",
|
||||
sock->fd);
|
||||
/* Press on... */
|
||||
@@ -1922,20 +1947,25 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr,
|
||||
switch (errno) {
|
||||
case EACCES:
|
||||
return (ISC_R_NOPERM);
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case EADDRNOTAVAIL:
|
||||
return (ISC_R_ADDRNOTAVAIL);
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case EADDRINUSE:
|
||||
return (ISC_R_ADDRINUSE);
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case EINVAL:
|
||||
return (ISC_R_BOUND);
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"bind: %s", strerror(errno));
|
||||
return (ISC_R_UNEXPECTED);
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user