-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proof of concept for MaxDispatches implementation #2598
Changes from 1 commit
6aadb09
89ed50d
fdcd7d8
e44ff3d
2bd882b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -969,6 +969,12 @@ public override void message(ThreadPoolCurrent current) | |
} | ||
} | ||
|
||
if (_maxDispatches > 0 && _dispatchCount == _maxDispatches) | ||
{ | ||
// Only read from the connection if max dispatches isn't reached. | ||
newOp &= ~SocketOperation.Read; | ||
bentoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// If the connection is not closed yet, we can update the thread pool selector to wait for | ||
// readiness of read, write or both operations. | ||
if (_state < StateClosed) | ||
|
@@ -1376,6 +1382,7 @@ internal ConnectionI( | |
_closeTimeout = options.closeTimeout; // not used for datagram connections | ||
// suppress inactivity timeout for datagram connections | ||
_inactivityTimeout = endpoint.datagram() ? TimeSpan.Zero : options.inactivityTimeout; | ||
_maxDispatches = options.maxDispatches; | ||
_removeFromFactory = removeFromFactory; | ||
_warn = initData.properties.getIcePropertyAsInt("Ice.Warn.Connections") > 0; | ||
_warnUdp = initData.properties.getIcePropertyAsInt("Ice.Warn.Datagrams") > 0; | ||
|
@@ -1647,31 +1654,40 @@ private void setState(int state) | |
case StateActive: | ||
{ | ||
// | ||
// Can only switch from holding or not validated to | ||
// active. | ||
// Can only switch to active from holding or not validated. | ||
// | ||
if (_state != StateHolding && _state != StateNotValidated) | ||
{ | ||
return; | ||
} | ||
|
||
if (_maxDispatches > 0 && _dispatchCount == _maxDispatches) | ||
bentoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
// Don't resume reading if maxDispatches is reached. | ||
return; | ||
} | ||
|
||
_threadPool.register(this, SocketOperation.Read); | ||
break; | ||
} | ||
|
||
case StateHolding: | ||
{ | ||
// | ||
// Can only switch from active or not validated to | ||
// holding. | ||
// Can only switch to holding from active or not validated. | ||
bentoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// | ||
if (_state != StateActive && _state != StateNotValidated) | ||
{ | ||
return; | ||
} | ||
if (_state == StateActive) | ||
|
||
if (_maxDispatches > 0 && _dispatchCount == _maxDispatches) | ||
bentoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
_threadPool.unregister(this, SocketOperation.Read); | ||
// Reads are already disabled if maxDispatches is reached. | ||
return; | ||
} | ||
|
||
_threadPool.unregister(this, SocketOperation.Read); | ||
bentoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
break; | ||
} | ||
|
||
|
@@ -2516,6 +2532,12 @@ private void sendResponse(OutgoingResponse response, bool isTwoWay, byte compres | |
sendMessage(new OutgoingMessage(response.outputStream, compress > 0, adopt: true)); | ||
} | ||
|
||
if (_maxDispatches > 0 && _state != StateHolding && _dispatchCount == _maxDispatches) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not following here. The _maxDispatches is "active" only state = StateHolding? Should it be only when state = StateActive? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you expect |
||
{ | ||
// Resume reads for this connection. | ||
_threadPool.update(this, SocketOperation.None, SocketOperation.Read); | ||
} | ||
|
||
--_dispatchCount; | ||
|
||
if (_state == StateClosing && _upcallCount == 0) | ||
|
@@ -2896,6 +2918,7 @@ internal void completed(LocalException ex) | |
|
||
// The number of outstanding dispatches. Maintained only while state is StateActive or StateHolding. | ||
private int _dispatchCount; | ||
private readonly int _maxDispatches; | ||
|
||
private int _state; // The current state. | ||
private bool _shutdownInitiated; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
_dispatchCount >= _maxDispatches
, since _dispatchCount can be incremented by more than 1 when we received a batch request?