- Notifications
You must be signed in to change notification settings - Fork5
Commitb85427f
committed
Attempt to fix some issues in our Windows socket code.
Make sure WaitLatchOrSocket regards FD_CLOSE as a read-ready condition.We might want to tweak this further, but it was surely wrong as-is.Make pgwin32_waitforsinglesocket detach its private event object from thepassed socket before returning. I suspect that failure to do so leadsto race conditions when other code (such as WaitLatchOrSocket) attachesa different event object to the same socket. Moreover, the existingcoding meant that repeated calls to pgwin32_waitforsinglesocket wouldperform ResetEvent on an event actively connected to a socket, whichis rumored to be an unsafe practice; the WSAEventSelect documentationappears to recommend against this, though it does not say not to do itin so many words.Also, uniformly use the coding pattern "WSAEventSelect(s, NULL, 0)" todetach events from sockets, rather than passing the event in the secondparameter. The WSAEventSelect documentation says that the second parameteris ignored if the third is 0, so theoretically this should make nodifference. However, elsewhere on the same reference page the use of NULLin this context is recommended, and I have found suggestions on the netthat some versions of Windows have bugs with a non-NULL second parameterin this usage.Some other mostly-cosmetic cleanup, such as using the right one ofWSAGetLastError and GetLastError for reporting errors from these functions.1 parentfd350ef commitb85427f
2 files changed
+36
-23
lines changedLines changed: 28 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
137 | 137 |
| |
138 | 138 |
| |
139 | 139 |
| |
| 140 | + | |
140 | 141 |
| |
141 | 142 |
| |
142 | 143 |
| |
| |||
150 | 151 |
| |
151 | 152 |
| |
152 | 153 |
| |
153 |
| - | |
154 |
| - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
155 | 157 |
| |
156 |
| - | |
157 | 158 |
| |
158 |
| - | |
159 |
| - | |
160 |
| - | |
161 | 159 |
| |
162 |
| - | |
163 |
| - | |
164 | 160 |
| |
165 | 161 |
| |
166 |
| - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
167 | 167 |
| |
168 | 168 |
| |
169 | 169 |
| |
| |||
196 | 196 |
| |
197 | 197 |
| |
198 | 198 |
| |
| 199 | + | |
| 200 | + | |
199 | 201 |
| |
| 202 | + | |
200 | 203 |
| |
201 | 204 |
| |
202 | 205 |
| |
| 206 | + | |
203 | 207 |
| |
204 | 208 |
| |
205 | 209 |
| |
| |||
210 | 214 |
| |
211 | 215 |
| |
212 | 216 |
| |
| 217 | + | |
| 218 | + | |
213 | 219 |
| |
214 | 220 |
| |
215 | 221 |
| |
| |||
219 | 225 |
| |
220 | 226 |
| |
221 | 227 |
| |
| 228 | + | |
| 229 | + | |
222 | 230 |
| |
| 231 | + | |
223 | 232 |
| |
224 |
| - | |
| 233 | + | |
225 | 234 |
| |
226 | 235 |
| |
227 | 236 |
| |
| |||
543 | 552 |
| |
544 | 553 |
| |
545 | 554 |
| |
546 |
| - | |
| 555 | + | |
547 | 556 |
| |
548 | 557 |
| |
| 558 | + | |
| 559 | + | |
| 560 | + | |
549 | 561 |
| |
550 | 562 |
| |
551 | 563 |
| |
| |||
565 | 577 |
| |
566 | 578 |
| |
567 | 579 |
| |
568 |
| - | |
569 |
| - | |
570 |
| - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
571 | 583 |
| |
572 | 584 |
| |
573 | 585 |
| |
| |||
594 | 606 |
| |
595 | 607 |
| |
596 | 608 |
| |
597 |
| - | |
| 609 | + | |
598 | 610 |
| |
599 | 611 |
| |
600 |
| - | |
| 612 | + | |
601 | 613 |
| |
602 | 614 |
| |
603 | 615 |
| |
|
Lines changed: 8 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
130 | 130 |
| |
131 | 131 |
| |
132 | 132 |
| |
| 133 | + | |
133 | 134 |
| |
134 | 135 |
| |
135 | 136 |
| |
136 |
| - | |
| 137 | + | |
137 | 138 |
| |
138 | 139 |
| |
139 | 140 |
| |
| |||
201 | 202 |
| |
202 | 203 |
| |
203 | 204 |
| |
204 |
| - | |
205 |
| - | |
206 |
| - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
207 | 208 |
| |
208 |
| - | |
| 209 | + | |
209 | 210 |
| |
210 | 211 |
| |
211 | 212 |
| |
| |||
233 | 234 |
| |
234 | 235 |
| |
235 | 236 |
| |
236 |
| - | |
| 237 | + | |
237 | 238 |
| |
238 | 239 |
| |
239 |
| - | |
| 240 | + | |
240 | 241 |
| |
241 | 242 |
| |
242 | 243 |
| |
|
0 commit comments
Comments
(0)