Added tests for Posix threads

This commit is contained in:
Michiel Broek 2003-11-29 14:45:39 +00:00
parent cb226754c0
commit be9fe37bcb
6 changed files with 274 additions and 1 deletions

View File

@ -308,3 +308,6 @@
/* Define if you have the <zlib.h> header file. */ /* Define if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H #undef HAVE_ZLIB_H
/* Define if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H

212
configure vendored
View File

@ -4490,6 +4490,214 @@ done
fi fi
echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5
echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6
if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char pthread_create ();
int
main ()
{
pthread_create ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_pthread_pthread_create=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_pthread_pthread_create=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5
echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6
if test $ac_cv_lib_pthread_pthread_create = yes; then
result=yes
else
result=no
fi
if test "$result" = "yes"; then
LIBS="$LIBS -lpthread"
for ac_header in pthread.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc in
yes:no )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
## Report this to bug-autoconf@gnu.org. ##
## ------------------------------------ ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
no:yes )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
## Report this to bug-autoconf@gnu.org. ##
## ------------------------------------ ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
PTHREADS=Yes
else
PTHREADS=No
fi
done
fi
echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo "$as_me:$LINENO: checking for ANSI C header files" >&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
if test "${ac_cv_header_stdc+set}" = set; then if test "${ac_cv_header_stdc+set}" = set; then
@ -10121,6 +10329,8 @@ echo "$as_me:$LINENO: result:
Version : ..................... ${VERSION} Version : ..................... ${VERSION}
Hydra zlib compression : ...... ${ZLIBSUP} Hydra zlib compression : ...... ${ZLIBSUP}
Posix threads : ............... ${PTHREADS}
" >&5 " >&5
echo "${ECHO_T} echo "${ECHO_T}
-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=- -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
@ -10129,6 +10339,8 @@ echo "${ECHO_T}
Version : ..................... ${VERSION} Version : ..................... ${VERSION}
Hydra zlib compression : ...... ${ZLIBSUP} Hydra zlib compression : ...... ${ZLIBSUP}
Posix threads : ............... ${PTHREADS}
" >&6 " >&6
if test x$ac_cv_c_compiler_gnu = xyes ; then if test x$ac_cv_c_compiler_gnu = xyes ; then

View File

@ -136,6 +136,12 @@ if test "$result" = "yes"; then
AC_CHECK_HEADERS(zlib.h,ZLIBSUP=Yes,ZLIBSUP=No) AC_CHECK_HEADERS(zlib.h,ZLIBSUP=Yes,ZLIBSUP=No)
fi fi
AC_CHECK_LIB(pthread,pthread_create,result=yes,result=no)
if test "$result" = "yes"; then
LIBS="$LIBS -lpthread"
AC_CHECK_HEADERS(pthread.h,PTHREADS=Yes,PTHREADS=No)
fi
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_HEADER_DIRENT AC_HEADER_DIRENT
@ -293,6 +299,8 @@ AC_MSG_RESULT([
Version : ..................... ${VERSION} Version : ..................... ${VERSION}
Hydra zlib compression : ...... ${ZLIBSUP} Hydra zlib compression : ...... ${ZLIBSUP}
Posix threads : ............... ${PTHREADS}
]) ])
if test x$ac_cv_c_compiler_gnu = xyes ; then if test x$ac_cv_c_compiler_gnu = xyes ; then

View File

@ -83,6 +83,7 @@
#include <setjmp.h> #include <setjmp.h>
#include <grp.h> #include <grp.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <pthread.h>
#ifdef HAVE_ICONV_H #ifdef HAVE_ICONV_H
#include <iconv.h> #include <iconv.h>
#endif #endif

View File

@ -54,6 +54,7 @@
#include "config.h" #include "config.h"
#include "md5b.h" #include "md5b.h"
#include "inbound.h" #include "inbound.h"
#include "mbcico.h"
/* /*
@ -77,6 +78,7 @@ static char *bstate[] = {
*/ */
void binkp_init(void); void binkp_init(void);
void binkp_deinit(void); void binkp_deinit(void);
void *binkp_readbuf(void);
char *unix2binkp(char *); char *unix2binkp(char *);
char *binkp2unix(char *); char *binkp2unix(char *);
int binkp_expired(void); int binkp_expired(void);
@ -130,6 +132,10 @@ int batchnr = 0, crc_errors = 0;
unsigned char *MD_challenge = NULL; /* Received CRAM challenge data */ unsigned char *MD_challenge = NULL; /* Received CRAM challenge data */
int ext_rand = 0; int ext_rand = 0;
static int read_state;
struct binkprec { struct binkprec {
int role; /* 1=orig, 0=answer */ int role; /* 1=orig, 0=answer */
int RxState; /* Receiver state */ int RxState; /* Receiver state */
@ -160,6 +166,8 @@ struct binkprec bp; /* Global structure */
void binkp_init(void) void binkp_init(void)
{ {
int frk;
bp.rname = calloc(512, sizeof(char)); bp.rname = calloc(512, sizeof(char));
bp.lname = calloc(512, sizeof(char)); bp.lname = calloc(512, sizeof(char));
bp.gname = calloc(512, sizeof(char)); bp.gname = calloc(512, sizeof(char));
@ -171,9 +179,17 @@ void binkp_init(void)
bp.Major = 1; bp.Major = 1;
bp.Minor = 0; bp.Minor = 0;
bp.DidSendGET = FALSE; bp.DidSendGET = FALSE;
read_state = 0;
frk = pthread_create(&threads[0], NULL, binkp_readbuf, NULL);
Syslog('-', "pthread_create returnd %d", frk);
Syslog('+', "Binkp: init complete");
} }
void binkp_deinit(void) void binkp_deinit(void)
{ {
if (bp.rname) if (bp.rname)
@ -185,6 +201,29 @@ void binkp_deinit(void)
} }
/*
* Read buffer, executed in a second process
*/
void *binkp_readbuf(void)
{
/*
* Just for testing
*/
Syslog('!', "Entering binkp_readbuf");
while (TRUE) {
read_state++;
if (read_state > 20)
read_state = 0;
usleep(100000);
Syslog('!', "readstate now %d", read_state);
}
Syslog('!', "SHOULD NOT BE HERE");
}
int binkp(int role) int binkp(int role)
{ {
int rc = MBERR_OK; int rc = MBERR_OK;
@ -1240,6 +1279,8 @@ int binkp_batch(file_list *to_send)
while ((bp.RxState != RxDone) || (bp.TxState != TxDone)) { while ((bp.RxState != RxDone) || (bp.TxState != TxDone)) {
Nopper(); Nopper();
Syslog('-', "read state %d", read_state);
if (binkp_expired()) { if (binkp_expired()) {
Syslog('!', "Binkp: Transfer timeout"); Syslog('!', "Binkp: Transfer timeout");
Syslog('b', "Binkp: TxState=%s, RxState=%s, rxlen=%d", txstate[bp.TxState], rxstate[bp.RxState], rxlen); Syslog('b', "Binkp: TxState=%s, RxState=%s, rxlen=%d", txstate[bp.TxState], rxstate[bp.RxState], rxlen);

View File

@ -1,9 +1,17 @@
#ifndef _MBCICO_H #ifndef _MBCICO_H
#define _MBCICO_H #define _MBCICO_H
/* $Id$ */
/*
* Global threads for mbcico
*/
#define NUM_THREADS 4
pthread_t threads[NUM_THREADS];
void usage(void); void usage(void);
void free_mem(void); void free_mem(void);
void die(int); void die(int);
#endif #endif