Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AsyncRequestCallback()

void System.Net.FtpWebRequest.AsyncRequestCallback ( object obj)
inlineprivate

Definition at line 1116 of file FtpWebRequest.cs.

1117 {
1118 RequestStage stage = RequestStage.CheckForError;
1119 try
1120 {
1121 FtpControlStream ftpControlStream = obj as FtpControlStream;
1122 FtpDataStream ftpDataStream = obj as FtpDataStream;
1123 Exception ex = obj as Exception;
1124 bool flag = obj == null;
1125 if (System.Net.NetEventSource.Log.IsEnabled())
1126 {
1127 System.Net.NetEventSource.Info(this, $"stream:{ftpDataStream} conn:{ftpControlStream} exp:{ex} completedRequest:{flag}", "AsyncRequestCallback");
1128 }
1129 while (true)
1130 {
1131 if (ex != null)
1132 {
1133 if (AttemptedRecovery(ex))
1134 {
1135 ftpControlStream = CreateConnection();
1136 if (ftpControlStream == null)
1137 {
1138 return;
1139 }
1140 ex = null;
1141 }
1142 if (ex != null)
1143 {
1144 SetException(ex);
1145 return;
1146 }
1147 }
1148 if (ftpControlStream == null)
1149 {
1150 break;
1151 }
1152 lock (_syncObject)
1153 {
1154 if (_aborted)
1155 {
1156 if (System.Net.NetEventSource.Log.IsEnabled())
1157 {
1158 System.Net.NetEventSource.Info(this, $"Releasing connect:{ftpControlStream}", "AsyncRequestCallback");
1159 }
1160 ftpControlStream.CloseSocket();
1161 return;
1162 }
1163 _connection = ftpControlStream;
1164 if (System.Net.NetEventSource.Log.IsEnabled())
1165 {
1166 System.Net.NetEventSource.Associate(this, _connection, "AsyncRequestCallback");
1167 }
1168 }
1169 try
1170 {
1171 ftpDataStream = (FtpDataStream)TimedSubmitRequestHelper(isAsync: true);
1172 return;
1173 }
1174 catch (Exception ex2)
1175 {
1176 ex = ex2;
1177 }
1178 }
1179 if (ftpDataStream != null)
1180 {
1181 lock (_syncObject)
1182 {
1183 if (_aborted)
1184 {
1185 ((ICloseEx)ftpDataStream).CloseEx(CloseExState.Abort | CloseExState.Silent);
1186 return;
1187 }
1188 _stream = ftpDataStream;
1189 }
1190 ftpDataStream.SetSocketTimeoutOption(Timeout);
1192 stage = (ftpDataStream.CanRead ? RequestStage.ReadReady : RequestStage.WriteReady);
1193 }
1194 else
1195 {
1196 if (!flag)
1197 {
1198 throw new System.Net.InternalException();
1199 }
1200 ftpControlStream = _connection;
1201 if (ftpControlStream != null)
1202 {
1204 _ftpWebResponse.UpdateStatus(ftpControlStream.StatusCode, ftpControlStream.StatusLine, ftpControlStream.ExitMessage);
1205 }
1206 stage = RequestStage.ReleaseConnection;
1207 }
1208 }
1209 catch (Exception exception)
1210 {
1212 }
1213 finally
1214 {
1215 FinishRequestStage(stage);
1216 }
1217 }
FtpControlStream CreateConnection()
bool AttemptedRecovery(Exception e)
FtpControlStream _connection
FtpWebResponse _ftpWebResponse
void EnsureFtpWebResponse(Exception exception)
RequestStage FinishRequestStage(RequestStage stage)
Stream TimedSubmitRequestHelper(bool isAsync)
void SetException(Exception exception)
void UpdateStatus(FtpStatusCode statusCode, string statusLine, string exitMessage)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Associate(object first, object second, [CallerMemberName] string memberName=null)

References System.Net.NetEventSource.Associate(), System.Net.NetworkStreamWrapper.CloseSocket(), System.exception, System.Net.FtpControlStream.ExitMessage, System.Net.NetEventSource.Info(), System.Net.NetEventSource.Log, System.obj, System.Net.FtpDataStream.SetSocketTimeoutOption(), System.Net.FtpControlStream.StatusCode, System.Net.FtpControlStream.StatusLine, and System.Net.FtpWebResponse.UpdateStatus().