Return true unless reaped
| 2232 | |
| 2233 | // Return true unless reaped |
| 2234 | static bool pconnection_write(pconnection_t *pc, pn_bytes_t wbuf) { |
| 2235 | ssize_t n; |
| 2236 | bool wouldblock; |
| 2237 | { |
| 2238 | csguard g(&pc->context.proactor->write_lock); |
| 2239 | n = pni_iocp_begin_write(pc->psocket.iocpd, wbuf.start, wbuf.size, &wouldblock, pc->psocket.iocpd->error); |
| 2240 | } |
| 2241 | if (n > 0) { |
| 2242 | pn_connection_driver_write_done(&pc->driver, n); |
| 2243 | } else if (n < 0 && !wouldblock) { |
| 2244 | psocket_error(&pc->psocket, WSAGetLastError(), "on write to"); |
| 2245 | } |
| 2246 | else if (wbuf.size == 0 && pn_connection_driver_write_closed(&pc->driver)) { |
| 2247 | if (pc->context.proactor->reaper->add(pc->psocket.iocpd)) { |
| 2248 | pc->psocket.iocpd = NULL; |
| 2249 | return false; |
| 2250 | } |
| 2251 | } |
| 2252 | return true; |
| 2253 | } |
| 2254 | |
| 2255 | // Queue the result (if any) for the one worker thread. Become the worker if possible. |
| 2256 | // NULL result is a wakeup or a topup. |
no test coverage detected