added sendfile for solaris using sendfilev

This commit is contained in:
hyung-hwan 2012-01-13 14:56:41 +00:00
parent 60ad0283bc
commit d48f69568c
5 changed files with 446 additions and 226 deletions

507
qse/configure vendored
View File

@ -762,12 +762,12 @@ PTHREAD_CFLAGS
PTHREAD_LIBS
PTHREAD_CC
ax_pthread_config
SENDFILE_LIBS
SOCKET_LIBS
ENABLE_CXX_FALSE
ENABLE_CXX_TRUE
BUILD_MODE
CHAR_MODE
SENDFILE_LIBS
SOCKET_LIBS
LIBM
WIN32_FALSE
WIN32_TRUE
@ -15559,6 +15559,316 @@ done
LIBS="$OLDLIBS"
for ac_func in connect gethostbyname
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
if test "$ac_cv_func_gethostbyname" = "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5
$as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char gethostbyname ();
int
main ()
{
return gethostbyname ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nsl_gethostbyname=yes
else
ac_cv_lib_nsl_gethostbyname=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5
$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then :
SOCKET_LIBS="$SOCKET_LIBS -lnsl"
$as_echo "#define HAVE_GETHOSTBYNAME 1" >>confdefs.h
fi
fi
if test "$ac_cv_func_connect" = "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5
$as_echo_n "checking for connect in -lsocket... " >&6; }
if test "${ac_cv_lib_socket_connect+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char connect ();
int
main ()
{
return connect ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_socket_connect=yes
else
ac_cv_lib_socket_connect=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5
$as_echo "$ac_cv_lib_socket_connect" >&6; }
if test "x$ac_cv_lib_socket_connect" = x""yes; then :
SOCKET_LIBS="$SOCKET_LIBS -lsocket"
$as_echo "#define HAVE_CONNECT 1" >>confdefs.h
fi
fi
for ac_func in sendfile sendfile64 sendfilev sendfilev64
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
if test "$ac_cv_func_sendfile" = "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sendfile in -lsendfile" >&5
$as_echo_n "checking for sendfile in -lsendfile... " >&6; }
if test "${ac_cv_lib_sendfile_sendfile+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsendfile $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sendfile ();
int
main ()
{
return sendfile ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_sendfile_sendfile=yes
else
ac_cv_lib_sendfile_sendfile=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sendfile_sendfile" >&5
$as_echo "$ac_cv_lib_sendfile_sendfile" >&6; }
if test "x$ac_cv_lib_sendfile_sendfile" = x""yes; then :
SENDFILE_LIBS="-lsendfile"
$as_echo "#define HAVE_SENDFILE 1" >>confdefs.h
fi
fi
if test "$ac_cv_func_sendfile64" = "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sendfile64 in -lsendfile" >&5
$as_echo_n "checking for sendfile64 in -lsendfile... " >&6; }
if test "${ac_cv_lib_sendfile_sendfile64+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsendfile $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sendfile64 ();
int
main ()
{
return sendfile64 ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_sendfile_sendfile64=yes
else
ac_cv_lib_sendfile_sendfile64=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sendfile_sendfile64" >&5
$as_echo "$ac_cv_lib_sendfile_sendfile64" >&6; }
if test "x$ac_cv_lib_sendfile_sendfile64" = x""yes; then :
SENDFILE_LIBS="-lsendfile"
$as_echo "#define HAVE_SENDFILE64 1" >>confdefs.h
fi
fi
if test "$ac_cv_func_sendfilev" = "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sendfilev in -lsendfile" >&5
$as_echo_n "checking for sendfilev in -lsendfile... " >&6; }
if test "${ac_cv_lib_sendfile_sendfilev+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsendfile $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sendfilev ();
int
main ()
{
return sendfilev ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_sendfile_sendfilev=yes
else
ac_cv_lib_sendfile_sendfilev=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sendfile_sendfilev" >&5
$as_echo "$ac_cv_lib_sendfile_sendfilev" >&6; }
if test "x$ac_cv_lib_sendfile_sendfilev" = x""yes; then :
SENDFILE_LIBS="-lsendfile"
$as_echo "#define HAVE_SENDFILEV 1" >>confdefs.h
fi
fi
if test "$ac_cv_func_sendfilev64" = "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sendfilev64 in -lsendfile" >&5
$as_echo_n "checking for sendfilev64 in -lsendfile... " >&6; }
if test "${ac_cv_lib_sendfile_sendfilev64+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsendfile $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sendfilev64 ();
int
main ()
{
return sendfilev64 ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_sendfile_sendfilev64=yes
else
ac_cv_lib_sendfile_sendfilev64=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sendfile_sendfilev64" >&5
$as_echo "$ac_cv_lib_sendfile_sendfilev64" >&6; }
if test "x$ac_cv_lib_sendfile_sendfilev64" = x""yes; then :
SENDFILE_LIBS="-lsendfile"
$as_echo "#define HAVE_SENDFILEV64 1" >>confdefs.h
fi
fi
ac_header_dirent=no
for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
@ -17069,199 +17379,6 @@ else
fi
OLDLIBS="$LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5
$as_echo_n "checking for library containing gethostbyname... " >&6; }
if test "${ac_cv_search_gethostbyname+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char gethostbyname ();
int
main ()
{
return gethostbyname ();
;
return 0;
}
_ACEOF
for ac_lib in '' nsl; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_gethostbyname=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if test "${ac_cv_search_gethostbyname+set}" = set; then :
break
fi
done
if test "${ac_cv_search_gethostbyname+set}" = set; then :
else
ac_cv_search_gethostbyname=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5
$as_echo "$ac_cv_search_gethostbyname" >&6; }
ac_res=$ac_cv_search_gethostbyname
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
LIBS="$OLDLIBS"
if test "$ac_cv_search_gethostbyname" != "none required" -a "$ac_cv_search_gethostbyname" != "no"
then
SOCKET_LIBS="$SOCKET_LIBS -lnsl"
fi
OLDLIBS="$LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5
$as_echo_n "checking for library containing socket... " >&6; }
if test "${ac_cv_search_socket+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char socket ();
int
main ()
{
return socket ();
;
return 0;
}
_ACEOF
for ac_lib in '' socket; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_socket=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if test "${ac_cv_search_socket+set}" = set; then :
break
fi
done
if test "${ac_cv_search_socket+set}" = set; then :
else
ac_cv_search_socket=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5
$as_echo "$ac_cv_search_socket" >&6; }
ac_res=$ac_cv_search_socket
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
LIBS="$OLDLIBS"
if test "$ac_cv_search_socket" != "none required" -a "$ac_cv_search_socket" != "no"
then
SOCKET_LIBS="$SOCKET_LIBS -lsocket"
fi
OLDLIBS="$LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sendfile" >&5
$as_echo_n "checking for library containing sendfile... " >&6; }
if test "${ac_cv_search_sendfile+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sendfile ();
int
main ()
{
return sendfile ();
;
return 0;
}
_ACEOF
for ac_lib in '' sendfile; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_sendfile=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if test "${ac_cv_search_sendfile+set}" = set; then :
break
fi
done
if test "${ac_cv_search_sendfile+set}" = set; then :
else
ac_cv_search_sendfile=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sendfile" >&5
$as_echo "$ac_cv_search_sendfile" >&6; }
ac_res=$ac_cv_search_sendfile
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
LIBS="$OLDLIBS"
if test "$ac_cv_search_sendfile" != "none required" -a "$ac_cv_search_socket" != "no"
then
SENDFILE_LIBS="$SENDFILE_LIBS -lsendfile"
fi
# Check whether --enable-reentrant was given.
if test "${enable_reentrant+set}" = set; then :
enableval=$enable_reentrant; enable_reentrant_is=$enableval

View File

@ -108,6 +108,64 @@ AC_CHECK_FUNCS([pow fmod sin cos tan atan atan2 log exp sqrt])
AC_CHECK_FUNCS([powf fmodf sinf cosf tanf atanf atan2f logf expf sqrtf])
LIBS="$OLDLIBS"
dnl OLDLIBS="$LIBS"
dnl AC_SEARCH_LIBS([connect], [socket])
dnl LIBS="$OLDLIBS"
dnl if test "$ac_cv_search_connect" != "none required" -a "$ac_cv_search_connect" != "no"
dnl then
dnl SOCKET_LIBS="$SOCKET_LIBS -lsocket"
dnl fi
dnl AC_SUBST(SOCKET_LIBS)
AC_CHECK_FUNCS([connect gethostbyname])
if test "$ac_cv_func_gethostbyname" = "no"
then
AC_CHECK_LIB([nsl], [gethostbyname], [
SOCKET_LIBS="$SOCKET_LIBS -lnsl"
AC_DEFINE(HAVE_GETHOSTBYNAME, 1)
])
fi
if test "$ac_cv_func_connect" = "no"
then
AC_CHECK_LIB([socket], [connect], [
SOCKET_LIBS="$SOCKET_LIBS -lsocket"
AC_DEFINE(HAVE_CONNECT, 1)
])
fi
AC_SUBST(SOCKET_LIBS)
dnl check if sendfile and its variants exist in the standard c library
dnl it inspects the existence of each missing function in the sendfile library.
AC_CHECK_FUNCS([sendfile sendfile64 sendfilev sendfilev64])
if test "$ac_cv_func_sendfile" = "no"
then
AC_CHECK_LIB([sendfile], [sendfile], [
SENDFILE_LIBS="-lsendfile"
AC_DEFINE(HAVE_SENDFILE, 1)
])
fi
if test "$ac_cv_func_sendfile64" = "no"
then
AC_CHECK_LIB([sendfile], [sendfile64], [
SENDFILE_LIBS="-lsendfile"
AC_DEFINE(HAVE_SENDFILE64, 1)
])
fi
if test "$ac_cv_func_sendfilev" = "no"
then
AC_CHECK_LIB([sendfile], [sendfilev], [
SENDFILE_LIBS="-lsendfile"
AC_DEFINE(HAVE_SENDFILEV, 1)
])
fi
if test "$ac_cv_func_sendfilev64" = "no"
then
AC_CHECK_LIB([sendfile], [sendfilev64], [
SENDFILE_LIBS="-lsendfile"
AC_DEFINE(HAVE_SENDFILEV64, 1)
])
fi
AC_SUBST(SENDFILE_LIBS)
AC_STRUCT_DIRENT_D_TYPE
AC_CHECK_MEMBERS([struct stat.st_birthtime])
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
@ -219,34 +277,6 @@ AC_ARG_ENABLE([cxx], [AS_HELP_STRING([--enable-cxx],[build the library for C++ i
[test "${HAVE_CXX}" = "yes" || enable_cxx_is="no"]
AM_CONDITIONAL(ENABLE_CXX, test "${enable_cxx_is}" = "yes" )
OLDLIBS="$LIBS"
AC_SEARCH_LIBS([gethostbyname], [nsl])
LIBS="$OLDLIBS"
if test "$ac_cv_search_gethostbyname" != "none required" -a "$ac_cv_search_gethostbyname" != "no"
then
SOCKET_LIBS="$SOCKET_LIBS -lnsl"
fi
OLDLIBS="$LIBS"
AC_SEARCH_LIBS([socket], [socket])
LIBS="$OLDLIBS"
if test "$ac_cv_search_socket" != "none required" -a "$ac_cv_search_socket" != "no"
then
SOCKET_LIBS="$SOCKET_LIBS -lsocket"
fi
AC_SUBST(SOCKET_LIBS)
OLDLIBS="$LIBS"
AC_SEARCH_LIBS([sendfile], [sendfile])
LIBS="$OLDLIBS"
if test "$ac_cv_search_sendfile" != "none required" -a "$ac_cv_search_socket" != "no"
then
SENDFILE_LIBS="$SENDFILE_LIBS -lsendfile"
fi
AC_SUBST(SENDFILE_LIBS)
AC_ARG_ENABLE([reentrant], [AS_HELP_STRING([--enable-reentrant],[define _REENTRANT (default. yes)])],
enable_reentrant_is=$enableval,enable_reentrant_is=yes)
if test "$enable_reentrant_is" = "yes"

View File

@ -27,6 +27,9 @@
/* Define to 1 if you have the `backtrace_symbols' function. */
#undef HAVE_BACKTRACE_SYMBOLS
/* Define to 1 if you have the `connect' function. */
#undef HAVE_CONNECT
/* Define to 1 if you have the `cos' function. */
#undef HAVE_COS
@ -73,6 +76,9 @@
/* Define to 1 if you have the `ftruncate64' function. */
#undef HAVE_FTRUNCATE64
/* Define to 1 if you have the `gethostbyname' function. */
#undef HAVE_GETHOSTBYNAME
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@ -133,6 +139,18 @@
/* Have PTHREAD_PRIO_INHERIT. */
#undef HAVE_PTHREAD_PRIO_INHERIT
/* Define to 1 if you have the `sendfile' function. */
#undef HAVE_SENDFILE
/* Define to 1 if you have the `sendfile64' function. */
#undef HAVE_SENDFILE64
/* Define to 1 if you have the `sendfilev' function. */
#undef HAVE_SENDFILEV
/* Define to 1 if you have the `sendfilev64' function. */
#undef HAVE_SENDFILEV64
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H

View File

@ -322,6 +322,7 @@ static int activate_listener (qse_httpd_t* httpd, listener_t* l)
/* TODO: suport https... */
sockaddr_t addr;
int s = -1, flag;
int addrsize;
QSE_ASSERT (l->handle <= -1);
@ -339,6 +340,7 @@ static int activate_listener (qse_httpd_t* httpd, listener_t* l)
addr.in4.sin_family = l->family;
addr.in4.sin_addr = l->addr.in4;
addr.in4.sin_port = htons (l->port);
addrsize = QSE_SIZEOF(addr.in4);
break;
}
@ -349,6 +351,7 @@ static int activate_listener (qse_httpd_t* httpd, listener_t* l)
addr.in6.sin6_addr = l->addr.in6;
addr.in6.sin6_port = htons (l->port);
/* TODO: addr.in6.sin6_scope_id */
addrsize = QSE_SIZEOF(addr.in6);
break;
}
#endif
@ -359,7 +362,10 @@ static int activate_listener (qse_httpd_t* httpd, listener_t* l)
}
}
if (bind (s, (struct sockaddr*)&addr, QSE_SIZEOF(addr)) <= -1) goto oops_esocket;
/* Solaris 8 returns EINVAL if QSE_SIZEOF(addr) is passed in as the
* address size for AF_INET. */
/*if (bind (s, (struct sockaddr*)&addr, QSE_SIZEOF(addr)) <= -1) goto oops_esocket;*/
if (bind (s, (struct sockaddr*)&addr, addrsize) <= -1) goto oops_esocket;
if (listen (s, 10) <= -1) goto oops_esocket;
flag = fcntl (s, F_GETFL);

View File

@ -38,12 +38,57 @@
#if defined(HAVE_SYS_SENDFILE_H)
# include <sys/sendfile.h>
#endif
#if defined(HAVE_SENDFILE) && defined(HAVE_SENDFILE64)
# if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64)
# define xsendfile sendfile64
# else
# define xsendfile sendfile
# endif
#elif defined(HAVE_SENDFILE)
# define xsendfile sendfile
#elif defined(HAVE_SENDFILE64)
# define xsendfile sendfile64
#elif defined(HAVE_SENDFILEV) || defined(HAVE_SENDFILEV64)
static qse_ssize_t xsendfile (
int out_fd, int in_fd, qse_foff_t* offset, qse_size_t count)
{
#if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64)
struct sendfilevec64 vec;
#else
struct sendfilevec vec;
#endif
size_t xfer;
ssize_t n;
vec.sfv_fd = in_fd;
vec.sfv_flag = 0;
if (offset)
{
vec.sfv_off = *offset;
}
else
{
vec.sfv_off = lseek (in_fd, 0, SEEK_CUR); /* TODO: lseek64 or llseek.. */
if (vec.sfv_off == (off_t)-1) return (qse_ssize_t)-1;
}
vec.sfv_len = count;
#if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64)
n = sendfilev64 (out_fd, &vec, 1, &xfer);
#else
n = sendfilev (out_fd, &vec, 1, &xfer);
#endif
if (offset) *offset = *offset + xfer;
/* TODO: xfer contains number of byte written even on failure
on success xfer == n.
on failure xfer != n.
*/
return n;
}
#else
@ -53,7 +98,7 @@ static qse_ssize_t xsendfile (
qse_mchar_t buf[MAX_SEND_SIZE];
qse_ssize_t n;
if (offset && lseek (in_fd, *offset, SEEK_SET) != *offset)
if (offset && lseek (in_fd, *offset, SEEK_SET) != *offset) //* 64bit version of lseek...
return (qse_ssize_t)-1;
if (count > QSE_COUNTOF(buf)) count = QSE_COUNTOF(buf);
@ -404,7 +449,11 @@ static int task_main_file (
count
);
if (n <= -1) return -1; /* TODO: any logging */
if (n <= -1)
{
// HANDLE EGAIN specially???
return -1; /* TODO: any logging */
}
if (n == 0 && count > 0)
{