try ditching pthreads and using straight-up errno.

it seems perhaps each clone() gets its own copy of
errno now?
This commit is contained in:
Matt Wells 2013-11-17 19:43:20 -07:00
parent 91279ff475
commit 5022ea4d6e
2 changed files with 18 additions and 5 deletions

View File

@ -84,7 +84,12 @@ else
# you might have to do apt-get install gcc-multilib to ensure that -m32 works.
# -m32 should use /usr/lib32/ as the library path.
# i also provide 32-bit libraries for linking that are not so easy to get.
CPPFLAGS = -m32 -g -Wall -pipe -Wno-write-strings -Wstrict-aliasing=0 -Wno-uninitialized -static -D_PTHREADS_ -Wno-unused-but-set-variable
#
# mdw. 11/17/2013. i took out the -D_PTHREADS_ flag.
# trying to use good ole' clone() again because it seems the errno location
# thing is fixed by just ignoring it.
#
CPPFLAGS = -m32 -g -Wall -pipe -Wno-write-strings -Wstrict-aliasing=0 -Wno-uninitialized -static -Wno-unused-but-set-variable
LIBS= -L. ./libz.a ./libssl.a ./libcrypto.a ./libiconv.a ./libm.a ./libstdc++.a -lpthread
endif

View File

@ -95,9 +95,9 @@ static long s_badPid = -1;
#ifndef _PTHREADS_
static int s_errno ;
static int s_errnos [ MAX_PID + 1 ];
//static int s_errno ;
//static int s_errnos [ MAX_PID + 1 ];
/*
// this was improvised from linuxthreads/errno.c
//#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
// WARNING: you MUST compile with -DREENTRANT for this to work
@ -109,7 +109,7 @@ int *__errno_location (void) {
s_badPid = pid;
return &s_errno;
}
*/
#endif
// this also limit the maximum number of outstanding (live) threads
@ -873,6 +873,9 @@ bool ThreadQueue::timedCleanUp ( long maxNiceness ) {
#ifndef _PTHREADS_
// MDW: i hafta take this out because the errno_location thing
// is not working on the newer gcc
/*
i am just using straight out errno. it seems different
for each thread now.
if ( ! t->m_isDone && t->m_pid >= 0 &&
s_errnos [t->m_pid] == 0x7fffffff ) {
log("thread: Got abnormal thread termination. Seems "
@ -880,6 +883,7 @@ bool ThreadQueue::timedCleanUp ( long maxNiceness ) {
s_errnos[t->m_pid] = 0;
goto again;
}
*/
#endif
// skip if not done yet
if ( ! t->m_isDone ) continue;
@ -1207,6 +1211,9 @@ bool ThreadQueue::cleanUp ( ThreadEntry *tt , long maxNiceness ) {
#ifndef _PTHREADS_
// MDW: i hafta take this out because the errno_location thing
// is not working on the newer gcc
/*
i am just using straight out errno. it seems different
for each thread now.
if ( ! t->m_isDone && t->m_pid >= 0 &&
s_errnos [t->m_pid] == 0x7fffffff ) {
log("thread: Got abnormal thread termination. Seems "
@ -1214,6 +1221,7 @@ bool ThreadQueue::cleanUp ( ThreadEntry *tt , long maxNiceness ) {
s_errnos[t->m_pid] = 0;
goto again;
}
*/
#endif
// skip if not done yet
if ( ! t->m_isDone ) continue;