* Fixed the problem that an IPC-Server holds a lock on its pipe so that no

client could connect to it. Now a maximum of one client can connect to it.
 * Debugtest now shows an error immediately when it cant connect to a server
 * Use dbugsrv as default server name to start when no server is found
 * Set SendError when the startup of the debug-server failed
 * When connecting to the debug-server fails, clean up resources and set
   DebugDisabled to false, to avoid an AV on a second try

git-svn-id: trunk@12861 -
This commit is contained in:
joost 2009-03-07 14:06:43 +00:00
parent 9662260088
commit 1ce7a88d65
3 changed files with 24 additions and 5 deletions

View File

@ -21,6 +21,11 @@ Var
begin begin
SendMethodEnter('Program'); SendMethodEnter('Program');
If (SendError<>'') then
begin
Writeln('Error : ',SendError);
Exit;
end;
Repeat Repeat
Writeln('Enter message to send to debug server (STOP exits): '); Writeln('Enter message to send to debug server (STOP exits): ');
Write('> '); Write('> ');

View File

@ -50,6 +50,7 @@ ResourceString
SEntering = '> Entering '; SEntering = '> Entering ';
SExiting = '< Exiting '; SExiting = '< Exiting ';
SSeparator = '>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<'; SSeparator = '>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<';
SServerStartFailed = 'Failed to start debugserver. (%s)';
implementation implementation
@ -211,11 +212,14 @@ begin
With TProcess.Create(Nil) do With TProcess.Create(Nil) do
begin begin
Try Try
CommandLine:='debugserver'; CommandLine:='dbugsrv';
Execute; Execute;
Result:=ProcessID; Result:=ProcessID;
Except Except On E: Exception do
begin
SendError := Format(SServerStartFailed,[E.Message]);
Result := 0; Result := 0;
end;
end; end;
Free; Free;
end; end;
@ -258,6 +262,7 @@ begin
if ServerID = 0 then if ServerID = 0 then
begin begin
DebugDisabled := True; DebugDisabled := True;
FreeAndNil(DebugClient);
Exit; Exit;
end end
else else
@ -269,7 +274,13 @@ begin
Sleep(100); Sleep(100);
end; end;
end; end;
DebugClient.Connect; try
DebugClient.Connect;
except
FreeAndNil(DebugClient);
DebugDisabled:=True;
Raise;
end;
MsgBuffer:=TMemoryStream.Create; MsgBuffer:=TMemoryStream.Create;
Msg.MsgType:=lctIdentify; Msg.MsgType:=lctIdentify;
Msg.MsgTimeStamp:=Now; Msg.MsgTimeStamp:=Now;

View File

@ -59,7 +59,10 @@ procedure TPipeClientComm.Connect;
begin begin
If Not ServerRunning then If Not ServerRunning then
Owner.DoError(SErrServerNotActive,[Owner.ServerID]); Owner.DoError(SErrServerNotActive,[Owner.ServerID]);
FStream:=TFileStream.Create(FFileName,fmOpenReadWrite); // Use this line to allow more then one client communicating with one server
// at the same time
// FStream:=TFileStream.Create(FFileName,fmOpenWrite+fmShareDenyNone);
FStream:=TFileStream.Create(FFileName,fmOpenWrite);
end; end;
procedure TPipeClientComm.Disconnect; procedure TPipeClientComm.Disconnect;
@ -127,7 +130,7 @@ begin
If not FileExists(FFileName) then If not FileExists(FFileName) then
If (fpmkFifo(FFileName,438)<>0) then If (fpmkFifo(FFileName,438)<>0) then
Owner.DoError(SErrFailedToCreatePipe,[FFileName]); Owner.DoError(SErrFailedToCreatePipe,[FFileName]);
FStream:=TFileStream.Create(FFileName,fmOpenReadWrite); FStream:=TFileStream.Create(FFileName,fmOpenReadWrite+fmShareDenyNone);
end; end;
procedure TPipeServerComm.StopServer; procedure TPipeServerComm.StopServer;