enterPotentialWriteReadDeadlock must be called before a write that could deadlock if the server is simultaneously blocked writing to us.
()
| 2105 | // enterPotentialWriteReadDeadlock must be called before a write that could deadlock if the server is simultaneously |
| 2106 | // blocked writing to us. |
| 2107 | func (pgConn *PgConn) enterPotentialWriteReadDeadlock() { |
| 2108 | // The time to wait is somewhat arbitrary. A Write should only take as long as the syscall and memcpy to the OS |
| 2109 | // outbound network buffer unless the buffer is full (which potentially is a block). It needs to be long enough for |
| 2110 | // the normal case, but short enough not to kill performance if a block occurs. |
| 2111 | // |
| 2112 | // In addition, on Windows the default timer resolution is 15.6ms. So setting the timer to less than that is |
| 2113 | // ineffective. |
| 2114 | if pgConn.slowWriteTimer.Reset(15 * time.Millisecond) { |
| 2115 | panic("BUG: slow write timer already active") |
| 2116 | } |
| 2117 | } |
| 2118 | |
| 2119 | // exitPotentialWriteReadDeadlock must be called after a call to enterPotentialWriteReadDeadlock. |
| 2120 | func (pgConn *PgConn) exitPotentialWriteReadDeadlock() { |
no test coverage detected