- Timestamp:
- Aug 25, 2010 12:40:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/poll-win.cpp
r31942 r31956 65 65 /** The events we're waiting for here. */ 66 66 uint32_t fEvents; 67 /** Saved events. */ 68 uint32_t fEventsSaved; 67 69 /** Set if this is the final entry for this handle. 68 70 * If the handle is entered more than once, this will be clear for all but … … 94 96 } RTPOLLSETINTERNAL; 95 97 98 /** 99 * Starts polling based on the handle type. 100 */ 101 static uint32_t rtPollHndStart(RTPOLLSETINTERNAL *pThis, PRTPOLLSETHNDENT pHnd, bool fNoWait) 102 { 103 uint32_t fEvents = 0; 104 105 switch (pHnd->enmType) 106 { 107 case RTHANDLETYPE_PIPE: 108 fEvents = rtPipePollStart(pHnd->u.hPipe, pThis, pHnd->fEvents, 109 pHnd->fFinalEntry, fNoWait); 110 break; 111 112 case RTHANDLETYPE_SOCKET: 113 fEvents = rtSocketPollStart(pHnd->u.hSocket, pThis, pHnd->fEvents, 114 pHnd->fFinalEntry, fNoWait); 115 break; 116 117 default: 118 AssertFailed(); 119 fEvents = UINT32_MAX; 120 break; 121 } 122 123 return fEvents; 124 } 125 126 /** 127 * Cleans up polling based on the handle type. 128 */ 129 static uint32_t rtPollHndDone(PRTPOLLSETHNDENT pHnd) 130 { 131 uint32_t fEvents = 0; 132 133 switch (pHnd->enmType) 134 { 135 case RTHANDLETYPE_PIPE: 136 fEvents = rtPipePollDone(pHnd->u.hPipe, pHnd->fEvents, 137 pHnd->fFinalEntry); 138 break; 139 140 case RTHANDLETYPE_SOCKET: 141 fEvents = rtSocketPollDone(pHnd->u.hSocket, pHnd->fEvents, 142 pHnd->fFinalEntry); 143 break; 144 145 default: 146 AssertFailed(); 147 fEvents = UINT32_MAX; 148 break; 149 } 150 151 return fEvents; 152 } 96 153 97 154 /** … … 125 182 for (i = 0; i < cHandles; i++) 126 183 { 127 switch (pThis->aHandles[i].enmType) 128 { 129 case RTHANDLETYPE_PIPE: 130 fEvents = rtPipePollStart(pThis->aHandles[i].u.hPipe, pThis, pThis->aHandles[i].fEvents, 131 pThis->aHandles[i].fFinalEntry, fNoWait); 132 break; 133 134 case RTHANDLETYPE_SOCKET: 135 fEvents = rtSocketPollStart(pThis->aHandles[i].u.hSocket, pThis, pThis->aHandles[i].fEvents, 136 pThis->aHandles[i].fFinalEntry, fNoWait); 137 break; 138 139 default: 140 AssertFailed(); 141 fEvents = UINT32_MAX; 142 break; 143 } 184 if (pThis->aHandles[i].fEventsSaved) 185 { 186 fEvents = pThis->aHandles[i].fEventsSaved; 187 pThis->aHandles[i].fEventsSaved = 0; 188 break; 189 } 190 191 fEvents = rtPollHndStart(pThis, &pThis->aHandles[i], fNoWait); 144 192 if (fEvents) 145 193 break; … … 163 211 while (i-- > 0) 164 212 { 165 switch (pThis->aHandles[i].enmType) 166 { 167 case RTHANDLETYPE_PIPE: 168 rtPipePollDone(pThis->aHandles[i].u.hPipe, pThis->aHandles[i].fEvents, 169 pThis->aHandles[i].fFinalEntry); 170 break; 171 172 case RTHANDLETYPE_SOCKET: 173 rtSocketPollDone(pThis->aHandles[i].u.hSocket, pThis->aHandles[i].fEvents, 174 pThis->aHandles[i].fFinalEntry); 175 break; 176 177 default: 178 AssertFailed(); 179 break; 180 } 213 pThis->aHandles[i].fEventsSaved = rtPollHndDone(&pThis->aHandles[i]); 181 214 } 182 215 … … 209 242 * Get event (if pending) and do wait cleanup. 210 243 */ 211 /** @todo r=aeichner: The loop below overwrites events if 212 * more than one source has events pending. 213 */ 214 i = cHandles; 215 while (i-- > 0) 216 { 217 fEvents = 0; 218 switch (pThis->aHandles[i].enmType) 219 { 220 case RTHANDLETYPE_PIPE: 221 fEvents = rtPipePollDone(pThis->aHandles[i].u.hPipe, pThis->aHandles[i].fEvents, 222 pThis->aHandles[i].fFinalEntry); 223 break; 224 225 case RTHANDLETYPE_SOCKET: 226 fEvents = rtSocketPollDone(pThis->aHandles[i].u.hSocket, pThis->aHandles[i].fEvents, 227 pThis->aHandles[i].fFinalEntry); 228 break; 229 230 default: 231 AssertFailed(); 232 break; 233 } 234 if (fEvents) 235 { 236 Assert(fEvents != UINT32_MAX); 237 if (pfEvents) 238 *pfEvents = fEvents; 239 if (pid) 240 *pid = pThis->aHandles[i].id; 241 rc = VINF_SUCCESS; 242 } 244 for (unsigned i = 0; i < cHandles; i++) 245 { 246 if (!fEvents) 247 { 248 fEvents = rtPollHndDone(&pThis->aHandles[i]); 249 250 if (fEvents) 251 { 252 Assert(fEvents != UINT32_MAX); 253 if (pfEvents) 254 *pfEvents = fEvents; 255 if (pid) 256 *pid = pThis->aHandles[i].id; 257 rc = VINF_SUCCESS; 258 } 259 } 260 else 261 pThis->aHandles[i].fEventsSaved = rtPollHndDone(&pThis->aHandles[i]); 243 262 } 244 263
Note:
See TracChangeset
for help on using the changeset viewer.