-
Notifications
You must be signed in to change notification settings - Fork 325
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
Fix socket exception on datacollection in parallel #1505
Changes from 7 commits
cc86add
014dcfb
a84629b
77a6181
ebb01e3
709508a
d08518f
c6d8c9b
f73c85f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,19 @@ internal static Task MessageLoopAsync( | |
CancellationToken cancellationToken) | ||
{ | ||
Exception error = null; | ||
var remoteEndPoint = ((IPEndPoint)client.Client.RemoteEndPoint).ToString(); | ||
var localEndPoint = ((IPEndPoint)client.Client.LocalEndPoint).ToString(); | ||
|
||
// Set read timeout to avoid blocking receive raw message | ||
while (channel != null && !cancellationToken.IsCancellationRequested) | ||
{ | ||
EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: loop starting: remoteendPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); | ||
|
||
try | ||
{ | ||
if (client.Client.Poll(STREAMREADTIMEOUT, SelectMode.SelectRead)) | ||
{ | ||
EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: NotifyDataAvailable remoteendPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); | ||
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.
Lets see logs for this 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. Done. |
||
channel.NotifyDataAvailable(); | ||
} | ||
} | ||
|
@@ -43,23 +48,29 @@ internal static Task MessageLoopAsync( | |
&& socketException.SocketErrorCode == SocketError.TimedOut) | ||
{ | ||
EqtTrace.Info( | ||
"Socket: Message loop: failed to receive message due to read timeout {0}", | ||
ioException); | ||
"Socket: Message loop: failed to receive message due to read timeout {0}, remoteendPoint: {1} localEndPoint: {2}", | ||
ioException, | ||
remoteEndPoint, | ||
localEndPoint); | ||
} | ||
else | ||
{ | ||
EqtTrace.Error( | ||
"Socket: Message loop: failed to receive message due to socket error {0}", | ||
ioException); | ||
"Socket: Message loop: failed to receive message due to socket error {0}, remoteendPoint: {1} localEndPoint: {2}", | ||
ioException, | ||
remoteEndPoint, | ||
localEndPoint); | ||
error = ioException; | ||
break; | ||
} | ||
} | ||
catch (Exception exception) | ||
{ | ||
EqtTrace.Error( | ||
"Socket: Message loop: failed to receive message {0}", | ||
exception); | ||
"Socket: Message loop: failed to receive message {0}, remoteendPoint: {1} localEndPoint: {2}", | ||
exception, | ||
remoteEndPoint, | ||
localEndPoint); | ||
error = exception; | ||
break; | ||
} | ||
|
@@ -68,6 +79,8 @@ internal static Task MessageLoopAsync( | |
// Try clean up and raise client disconnected events | ||
errorHandler(error); | ||
|
||
EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: exiting MessageLoopAsync remoteendPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); | ||
|
||
return Task.FromResult(0); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -596,6 +596,7 @@ private void SetOperationComplete() | |
EqtTrace.Verbose("TestRequestSender.SetOperationComplete: Setting operation complete."); | ||
} | ||
|
||
this.communicationEndpoint.Stop(); | ||
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. Do we need lock here? 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. Not required. |
||
Interlocked.CompareExchange(ref this.operationCompleted, 1, 0); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,8 @@ internal class ProxyDataCollectionManager : IProxyDataCollectionManager | |
private string settingsXml; | ||
private int connectionTimeout; | ||
private IRequestData requestData; | ||
private int dataCollectionPort; | ||
private int dataCollectionProcessId; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ProxyDataCollectionManager"/> class. | ||
|
@@ -126,6 +128,7 @@ public Collection<AttachmentSet> AfterTestRunEnd(bool isCanceled, ITestMessageEv | |
this.InvokeDataCollectionServiceAction( | ||
() => | ||
{ | ||
EqtTrace.Info("ProxyDataCollectionManager.AfterTestRunEnd: Get attachment set for datacollector processId: {0} port: {1}", dataCollectionProcessId, dataCollectionPort); | ||
attachmentSet = this.dataCollectionRequestSender.SendAfterTestRunStartAndGetResult(runEventsHandler, isCanceled); | ||
}, | ||
runEventsHandler); | ||
|
@@ -159,9 +162,15 @@ public DataCollectionParameters BeforeTestRunStart( | |
this.InvokeDataCollectionServiceAction( | ||
() => | ||
{ | ||
EqtTrace.Info("ProxyDataCollectionManager.BeforeTestRunStart: Get env variable and port for datacollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); | ||
var result = this.dataCollectionRequestSender.SendBeforeTestRunStartAndGetResult(this.settingsXml, runEventsHandler); | ||
environmentVariables = result.EnvironmentVariables; | ||
dataCollectionEventsPort = result.DataCollectionEventsPort; | ||
|
||
EqtTrace.Info( | ||
"ProxyDataCollectionManager.BeforeTestRunStart: SendBeforeTestRunStartAndGetResult successful, env variable from datacollector: {0} and testhost port: {1}", | ||
string.Join(";", environmentVariables), | ||
dataCollectionEventsPort); | ||
}, | ||
runEventsHandler); | ||
return new DataCollectionParameters( | ||
|
@@ -175,21 +184,27 @@ public DataCollectionParameters BeforeTestRunStart( | |
/// </summary> | ||
public void Dispose() | ||
{ | ||
EqtTrace.Info("ProxyDataCollectionManager.Dispose: calling dospose for datacollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); | ||
this.dataCollectionRequestSender.Close(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Initialize() | ||
{ | ||
var port = this.dataCollectionRequestSender.InitializeCommunication(); | ||
this.dataCollectionPort = this.dataCollectionRequestSender.InitializeCommunication(); | ||
|
||
// Warn the user that execution will wait for debugger attach. | ||
var processId = this.dataCollectionLauncher.LaunchDataCollector(null, this.GetCommandLineArguments(port)); | ||
this.dataCollectionProcessId = this.dataCollectionLauncher.LaunchDataCollector(null, this.GetCommandLineArguments(this.dataCollectionPort)); | ||
EqtTrace.Info("ProxyDataCollectionManager.Initialize: Launched datacollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); | ||
|
||
ChangeConnectionTimeoutIfRequired(dataCollectionProcessId); | ||
|
||
EqtTrace.Info("ProxyDataCollectionManager.Initialize: waiting for connection with timeout: {0}", this.connectionTimeout); | ||
|
||
ChangeConnectionTimeoutIfRequired(processId); | ||
var connected = this.dataCollectionRequestSender.WaitForRequestHandlerConnection(this.connectionTimeout); | ||
if (connected == false) | ||
{ | ||
EqtTrace.Error("ProxyDataCollectionManager.Initialize: failed to connect to datacollector process."); | ||
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. Add datacollector process ID we could not connect to 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. Done. |
||
throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, CrossPlatEngineResources.FailedToConnectDataCollector)); | ||
} | ||
} | ||
|
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.
do we need typecast?
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.
Done.