Skip to content

Commit

Permalink
Merge pull request microsoft#3 from David-Engel/feat_interIdle
Browse files Browse the repository at this point in the history
Fixed a few more tests
  • Loading branch information
VeryVerySpicy authored Sep 3, 2021
2 parents 423420c + 1bd8522 commit 056affd
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 117 deletions.
53 changes: 27 additions & 26 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,47 +101,49 @@ public String toString() {
}
}

private ExtendedSocketOptions() {
}
private ExtendedSocketOptions() {}

/**
* Keep-Alive idle time.
*
* <p>
* The value of this socket option is an {@code Integer} that is the number of seconds of idle time before keep-alive
* initiates a probe. The socket option is specific to stream-oriented sockets using the TCP/IP protocol. The exact
* semantics of this socket option are system dependent.
* The value of this socket option is an {@code Integer} that is the number of seconds of idle time before
* keep-alive initiates a probe. The socket option is specific to stream-oriented sockets using the TCP/IP protocol.
* The exact semantics of this socket option are system dependent.
*
* <p>
* When the {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} option is enabled, TCP probes a connection
* that has been idle for some amount of time. The default value for this idle period is system dependent, but is
* typically 2 hours. The {@code TCP_KEEPIDLE} option can be used to affect this value for a given socket.
* When the {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} option is enabled, TCP probes a
* connection that has been idle for some amount of time. The default value for this idle period is system
* dependent, but is typically 2 hours. The {@code TCP_KEEPIDLE} option can be used to affect this value for a given
* socket.
*
* @since 11
*/
public static final SocketOption<Integer> TCP_KEEPIDLE = new ExtSocketOption<Integer>("TCP_KEEPIDLE", Integer.class);
public static final SocketOption<Integer> TCP_KEEPIDLE = new ExtSocketOption<Integer>("TCP_KEEPIDLE",
Integer.class);

/**
* Keep-Alive retransmission interval time.
*
* <p>
* The value of this socket option is an {@code Integer} that is the number of seconds to wait before retransmitting a
* keep-alive probe. The socket option is specific to stream-oriented sockets using the TCP/IP protocol. The exact
* The value of this socket option is an {@code Integer} that is the number of seconds to wait before retransmitting
* a keep-alive probe. The socket option is specific to stream-oriented sockets using the TCP/IP protocol. The exact
* semantics of this socket option are system dependent.
*
* <p>
* When the {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} option is enabled, TCP probes a connection
* that has been idle for some amount of time. If the remote system does not respond to a keep-alive probe, TCP
* retransmits the probe after some amount of time. The default value for this retransmission interval is system
* dependent, but is typically 75 seconds. The {@code TCP_KEEPINTERVAL} option can be used to affect this value for a
* given socket.
* When the {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} option is enabled, TCP probes a
* connection that has been idle for some amount of time. If the remote system does not respond to a keep-alive
* probe, TCP retransmits the probe after some amount of time. The default value for this retransmission interval is
* system dependent, but is typically 75 seconds. The {@code TCP_KEEPINTERVAL} option can be used to affect this
* value for a given socket.
*
* @since 11
*/
public static final SocketOption<Integer> TCP_KEEPINTERVAL = new ExtSocketOption<Integer>("TCP_KEEPINTERVAL",
Integer.class);
}


final class TDS {
// TDS protocol versions
static final int VER_DENALI = 0x74000004; // TDS 7.4
Expand Down Expand Up @@ -1086,7 +1088,8 @@ final void setFilteredStream(InputStream is) {
* Poll the stream to verify connectivity.
*
* @return true if the stream is readable.
* @throws IOException If an I/O exception occurs.
* @throws IOException
* If an I/O exception occurs.
*/
public synchronized boolean poll() throws IOException {
synchronized (this) {
Expand Down Expand Up @@ -1203,8 +1206,8 @@ private int readInternal(byte[] b, int offset, int maxBytes) throws IOException

try {
byte[] bytesFromStream = new byte[maxBytes - bytesFromCache.length];
int bytesReadFromStream = filteredStream.read(bytesFromStream, offset - offsetBytesToSkipInCache,
maxBytes - bytesFromCache.length);
int bytesReadFromStream = filteredStream.read(bytesFromStream,
offset - offsetBytesToSkipInCache, maxBytes - bytesFromCache.length);
bytesRead = bytesFromCache.length + bytesReadFromStream;
System.arraycopy(bytesFromCache, 0, b, 0, bytesFromCache.length);
System.arraycopy(bytesFromStream, 0, b, bytesFromCache.length, bytesReadFromStream);
Expand Down Expand Up @@ -7493,6 +7496,7 @@ final void trySetSensitivityClassification(SensitivityClassification sensitivity
}
}


/**
* The tds default implementation of a timeout command
*/
Expand Down Expand Up @@ -7530,8 +7534,6 @@ public void interrupt() {
}




/**
* TDSCommand encapsulates an interruptable TDS conversation.
*
Expand Down Expand Up @@ -7698,7 +7700,7 @@ void createCounter(ICounter previousCounter, Properties activeConnectionProperti
counter = previousCounter;
}
}

synchronized void addToPoller() {
if (!registeredInPoller) {
// If command execution is subject to timeout then start timing until
Expand Down Expand Up @@ -8159,12 +8161,11 @@ final TDSReader startResponse(boolean isAdaptive) throws SQLServerException {
}

/*
* Currently only used in Connection Resiliency scenarios. This thread reference
* allows the current command to interrupt the thread if it's sleeping. This is useful
* in timeout cases.
* Currently only used in Connection Resiliency scenarios. This thread reference allows the current command to
* interrupt the thread if it's sleeping. This is useful in timeout cases.
*/
void attachThread(Thread reconnectThread) {
this.correspondingThread = reconnectThread;
this.correspondingThread = reconnectThread;
}
}

Expand Down
Loading

0 comments on commit 056affd

Please sign in to comment.