Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 3ac665c

Browse files
committed
Issue 13416: Remove libthr hack from core.thread.osthread
1 parent fb54942 commit 3ac665c

1 file changed

Lines changed: 0 additions & 61 deletions

File tree

src/core/thread/osthread.d

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,6 @@ else
196196
*/
197197
class Thread : ThreadBase
198198
{
199-
//
200-
// Main process thread
201-
//
202-
version (FreeBSD)
203-
{
204-
// set when suspend failed and should be retried, see Issue 13416
205-
private shared bool m_suspendagain;
206-
}
207-
208199
//
209200
// Standard thread data
210201
//
@@ -1841,7 +1832,6 @@ extern (C) void thread_suspendAll() nothrow
18411832
// subtract own thread
18421833
assert(cnt >= 1);
18431834
--cnt;
1844-
Lagain:
18451835
// wait for semaphore notifications
18461836
for (; cnt; --cnt)
18471837
{
@@ -1852,20 +1842,6 @@ extern (C) void thread_suspendAll() nothrow
18521842
errno = 0;
18531843
}
18541844
}
1855-
version (FreeBSD)
1856-
{
1857-
// avoid deadlocks, see Issue 13416
1858-
t = ThreadBase.sm_tbeg.toThread;
1859-
while (t)
1860-
{
1861-
auto tn = t.next;
1862-
if (t.m_suspendagain && suspend(t))
1863-
++cnt;
1864-
t = tn.toThread;
1865-
}
1866-
if (cnt)
1867-
goto Lagain;
1868-
}
18691845
}
18701846
}
18711847
}
@@ -2292,7 +2268,6 @@ else version (Posix)
22922268
status = sigdelset( &sigres, resumeSignalNumber );
22932269
assert( status == 0 );
22942270

2295-
version (FreeBSD) obj.m_suspendagain = false;
22962271
status = sem_post( &suspendCount );
22972272
assert( status == 0 );
22982273

@@ -2303,19 +2278,6 @@ else version (Posix)
23032278
obj.m_curr.tstack = obj.m_curr.bstack;
23042279
}
23052280
}
2306-
2307-
// avoid deadlocks on FreeBSD, see Issue 13416
2308-
version (FreeBSD)
2309-
{
2310-
auto obj = Thread.getThis();
2311-
if (THR_IN_CRITICAL(obj.m_addr))
2312-
{
2313-
obj.m_suspendagain = true;
2314-
if (sem_post(&suspendCount)) assert(0);
2315-
return;
2316-
}
2317-
}
2318-
23192281
callWithStackShell(&op);
23202282
}
23212283

@@ -2329,29 +2291,6 @@ else version (Posix)
23292291
{
23302292

23312293
}
2332-
2333-
// HACK libthr internal (thr_private.h) macro, used to
2334-
// avoid deadlocks in signal handler, see Issue 13416
2335-
version (FreeBSD) bool THR_IN_CRITICAL(pthread_t p) nothrow @nogc
2336-
{
2337-
import core.sys.posix.config : c_long;
2338-
import core.sys.posix.sys.types : lwpid_t;
2339-
2340-
// If the begin of pthread would be changed in libthr (unlikely)
2341-
// we'll run into undefined behavior, compare with thr_private.h.
2342-
static struct pthread
2343-
{
2344-
c_long tid;
2345-
static struct umutex { lwpid_t owner; uint flags; uint[2] ceilings; uint[4] spare; }
2346-
umutex lock;
2347-
uint cycle;
2348-
int locklevel;
2349-
int critical_count;
2350-
// ...
2351-
}
2352-
auto priv = cast(pthread*)p;
2353-
return priv.locklevel > 0 || priv.critical_count > 0;
2354-
}
23552294
}
23562295
}
23572296
else

0 commit comments

Comments
 (0)