From: sof Date: Thu, 15 Jul 2004 20:42:45 +0000 (+0000) Subject: [project @ 2004-07-15 20:42:45 by sof] X-Git-Tag: Initial_conversion_from_CVS_complete~1782 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=b87accfa195f0baa3ddf37c7593c0205ac444521;p=ghc-hetmet.git [project @ 2004-07-15 20:42:45 by sof] awaitEvent(): for Integrity, use socketpair() instead of pipe() to implement socket()-aborting mechanism --- diff --git a/ghc/rts/Select.c b/ghc/rts/Select.c index d7e6ffc..30e715e 100644 --- a/ghc/rts/Select.c +++ b/ghc/rts/Select.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Select.c,v 1.30 2003/10/01 10:49:09 wolfgang Exp $ + * $Id: Select.c,v 1.31 2004/07/15 20:42:45 sof Exp $ * * (c) The GHC Team 1995-2002 * @@ -35,6 +35,10 @@ #include #endif +#ifdef INTEGRITY +#include +#endif + /* last timestamp */ nat timestamp = 0; @@ -166,7 +170,19 @@ awaitEvent(rtsBool wait) #ifdef RTS_SUPPORTS_THREADS if(!workerWakeupInited) { +#if defined(INTEGRITY) + int arg; + int rc = socketpair(AF_LOCAL, SOCK_STREAM, 0, workerWakeupPipe); + if (rc == -1) { + printf("failed to create socketpair: %d\n", errno); + } + arg = fcntl(workerWakeupPipe[0], F_GETFL,0); + fcntl(workerWakeupPipe[0], F_SETFL, arg | O_NONBLOCK); + arg = fcntl(workerWakeupPipe[1], F_GETFL,0); + fcntl(workerWakeupPipe[1], F_SETFL, arg | O_NONBLOCK); +#else pipe(workerWakeupPipe); +#endif workerWakeupInited = rtsTrue; } FD_SET(workerWakeupPipe[0], &rfd); @@ -345,10 +361,9 @@ wakeBlockedWorkerThread() { if(isWorkerBlockedInAwaitEvent && !workerWakeupPending) { unsigned char dummy = 42; // Any value will do here - - // write something so that select() wakes up - write(workerWakeupPipe[1],&dummy,1); + // write something so that select() wakes up workerWakeupPending = rtsTrue; + write(workerWakeupPipe[1],&dummy,1); } }