我们有一个 Indy(版本 10.6.1.5235)TIdHttpServer“服务”,多年来一直与 Delphi 2007 配合良好。在最新的 Windows 更新(KB4338815 和 KB4338830)之后,我们注意到当 TIdHttpServer 设置为 false 时,服务会冻结。
我已经包含了创建 TIdHttpServer 的源代码。在我们的服务“停止”处理程序中,我们设置IdHttpServer1.Active为 False,这就是冻结的地方。当 Indy 尝试关闭 http 连接时,它似乎挂起。有解决办法吗?
更新一根据 Remy Lebeau,我创建了一个最小、完整且可验证的示例。这里是:
procedure TMainForm.Button1Click(Sender: TObject);
begin
memo1.clear;
iCall := 0;
IdHTTPServer1 := TIdHTTPServer.Create;
IdHTTPServer1.MaxConnections := 10;
IdHTTPServer1.AutoStartSession := True;
IdHTTPServer1.SessionState := True;
IdHTTPServer1.OnCommandGet := IdHTTPServer1CommandGet;
IdHTTPServer1.KeepAlive := False;
idHttpServer1.DefaultPort := 80;
if ReuseSocket.checked then
IDHTTPSERVER1.ReuseSocket := rsTrue;
IdHTTPServer1.Active := True;
end;
procedure TMainForm.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
iCall := iCall + 1;
if iCall mod 100 = 0 then
memo1.lines.add(inttostr(iCall)+ ' calls made');
AResponseInfo.ContentText := '<html><body>Hello There</body></html';
end;
procedure TMainForm.StopClick(Sender: TObject);
begin
try
IdHTTPServer1.Active := False;
memo1.lines.add('IdHTTPServer1.Active := False;');
except
on e: exception do
memo1.lines.add('Exception on IdHTTPServer1.Active := False; Message:'+e.message);
end;
end;
应用程序将正常运行,但一旦单击“停止”按钮,将 IdHttpServer Active 属性设置为 False,它就会挂起。
您可能遇到过类似的问题:
Windows 2012 R2 closesocket() 挂在监听套接字上 https://stackoverflow.com/questions/51359861/
该问题是由微软的补丁带来的KB4338815,这导致了closesocket
永远挂在英特尔至强处理器上
该问题已通过卸载解决KB4338815,您确实已经安装了。因此,请尝试卸载系统上的该知识库,看看是否可以解决您的问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)