Ticket #878: diffs

File diffs, 5.5 KB (added by guest, 9 years ago)
Line 
1diff -c src-ref/ghc-6.4.2.20060411/ghc/rts/win32/AsyncIO.c src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/AsyncIO.c
2*** src-ref/ghc-6.4.2.20060411/ghc/rts/win32/AsyncIO.c  Mon Aug  1 09:35:00 2005
3--- src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/AsyncIO.c Thu Aug 24 17:38:00 2006
4***************
5*** 44,51 ****
6  #define MAX_REQUESTS 200
7 
8  static CRITICAL_SECTION queue_lock;
9! static HANDLE           completed_req_event;
10! static HANDLE           abandon_req_wait;
11  static HANDLE           wait_handles[2];
12  static CompletedReq     completedTable[MAX_REQUESTS];
13  static int              completed_hw;
14--- 44,51 ----
15  #define MAX_REQUESTS 200
16 
17  static CRITICAL_SECTION queue_lock;
18! static HANDLE           completed_req_event = INVALID_HANDLE_VALUE;
19! static HANDLE           abandon_req_wait = INVALID_HANDLE_VALUE;
20  static HANDLE           wait_handles[2];
21  static CompletedReq     completedTable[MAX_REQUESTS];
22  static int              completed_hw;
23***************
24*** 172,178 ****
25  void
26  shutdownAsyncIO()
27  {
28!     CloseHandle(completed_req_event);
29      ShutdownIOManager();
30  }
31 
32--- 172,189 ----
33  void
34  shutdownAsyncIO()
35  {
36!     if (completed_req_event != INVALID_HANDLE_VALUE) {
37!         CloseHandle(completed_req_event);
38!       completed_req_event = INVALID_HANDLE_VALUE;
39!     }
40!     if (abandon_req_wait != INVALID_HANDLE_VALUE) {
41!         CloseHandle(abandon_req_wait);
42!       abandon_req_wait = INVALID_HANDLE_VALUE;
43!     }
44!     if (completed_table_sema != NULL) {
45!         CloseHandle(completed_table_sema);
46!       completed_table_sema = NULL;
47!     }
48      ShutdownIOManager();
49  }
50 
51diff -c src-ref/ghc-6.4.2.20060411/ghc/rts/win32/ConsoleHandler.c src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/ConsoleHandler.c
52*** src-ref/ghc-6.4.2.20060411/ghc/rts/win32/ConsoleHandler.c   Fri Apr 22 17:18:18 2005
53--- src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/ConsoleHandler.c  Thu Aug 24 17:38:00 2006
54***************
55*** 45,50 ****
56--- 45,58 ----
57      return;
58  }
59 
60+ void
61+ finiUserSignals(void)
62+ {
63+     if (hConsoleEvent != INVALID_HANDLE_VALUE) {
64+         CloseHandle(hConsoleEvent);
65+     }
66+ }
67+
68  /*
69   * Function: shutdown_handler()
70   *
71diff -c src-ref/ghc-6.4.2.20060411/ghc/rts/win32/IOManager.c src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/IOManager.c
72*** src-ref/ghc-6.4.2.20060411/ghc/rts/win32/IOManager.c        Fri Apr 22 17:17:46 2005
73--- src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/IOManager.c       Thu Aug 24 17:38:00 2006
74***************
75*** 80,85 ****
76--- 80,88 ----
77 
78        if (rc == WAIT_OBJECT_0) {
79            // we received the exit event
80+           EnterCriticalSection(&iom->manLock);
81+           ioMan->numWorkers--;
82+           LeaveCriticalSection(&iom->manLock);
83            return 0;
84        }
85 
86***************
87*** 435,446 ****
88 
89  void ShutdownIOManager ( void )
90  {
91!   SetEvent(ioMan->hExitEvent);
92!   // ToDo: we can't free this now, because the worker thread(s)
93!   // haven't necessarily finished with it yet.  Perhaps it should
94!   // have a reference count or something.
95!   // free(ioMan);
96!   // ioMan = NULL;
97  }
98 
99  /* Keep track of WorkItems currently being serviced. */
100--- 438,460 ----
101 
102  void ShutdownIOManager ( void )
103  {
104!     int num;
105!
106!     SetEvent(ioMan->hExitEvent);
107!   
108!     /* Wait for all worker threads to die. */
109!     for (;;) {
110!         EnterCriticalSection(&ioMan->manLock);
111!       num = ioMan->numWorkers;
112!       LeaveCriticalSection(&ioMan->manLock);
113!       if (num == 0)
114!           break;
115!       Sleep(10);
116!     }
117!     FreeWorkQueue(ioMan->workQueue);
118!     CloseHandle(ioMan->hExitEvent);
119!     free(ioMan);
120!     ioMan = NULL;
121  }
122 
123  /* Keep track of WorkItems currently being serviced. */
124diff -c src-ref/ghc-6.4.2.20060411/ghc/rts/win32/Ticker.c src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/Ticker.c
125*** src-ref/ghc-6.4.2.20060411/ghc/rts/win32/Ticker.c   Tue Mar 21 05:20:47 2006
126--- src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/Ticker.c  Thu Aug 24 17:38:00 2006
127***************
128*** 115,120 ****
129--- 115,121 ----
130            }
131            if (exitCode != STILL_ACTIVE) {
132                tickThread = INVALID_HANDLE_VALUE;
133+               CloseHandle(hStopEvent);
134                return 0;
135            }
136            TerminateThread(tickThread, 0);
137diff -c src-ref/ghc-6.4.2.20060411/ghc/rts/win32/WorkQueue.c src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/WorkQueue.c
138*** src-ref/ghc-6.4.2.20060411/ghc/rts/win32/WorkQueue.c        Fri Sep 12 10:42:36 2003
139--- src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/win32/WorkQueue.c       Thu Aug 24 19:03:33 2006
140***************
141*** 45,52 ****
142      return wq;
143    }
144     
145!   wq->head   = 0;
146!   wq->tail   = 0;
147   
148    InitializeCriticalSection(&wq->queueLock);
149    wq->workAvailable = newSemaphore(0, WORKQUEUE_SIZE);
150--- 45,51 ----
151      return wq;
152    }
153     
154!   memset(wq, 0, sizeof *wq);
155   
156    InitializeCriticalSection(&wq->queueLock);
157    wq->workAvailable = newSemaphore(0, WORKQUEUE_SIZE);
158***************
159*** 65,70 ****
160--- 64,78 ----
161  void
162  FreeWorkQueue ( WorkQueue* pq )
163  {
164+   int i;
165+
166+   /* Free any remaining work items. */
167+   for (i = 0; i < WORKQUEUE_SIZE; i++) {
168+     if (pq->items[i] != NULL) {
169+       free(pq->items[i]);
170+     }
171+   }
172+
173    /* Close the semaphores; any threads blocked waiting
174     * on either will as a result be woken up.
175     */
176***************
177*** 72,78 ****
178      CloseHandle(pq->workAvailable);
179    }
180    if ( pq->roomAvailable ) {
181!     CloseHandle(pq->workAvailable);
182    }
183    free(pq);
184    return;
185--- 80,86 ----
186      CloseHandle(pq->workAvailable);
187    }
188    if ( pq->roomAvailable ) {
189!     CloseHandle(pq->roomAvailable);
190    }
191    free(pq);
192    return;