dcd, unix, wait propertly for the socket to be ready

This commit is contained in:
Basile Burg 2016-02-08 12:09:22 +01:00
parent d92eb999ee
commit 6ee4cb1927
2 changed files with 37 additions and 9 deletions

View File

@ -10,7 +10,7 @@ uses
ce_observer, ce_libman, ce_tools, ce_dcd, ce_main, ce_writableComponent, ce_observer, ce_libman, ce_tools, ce_dcd, ce_main, ce_writableComponent,
ce_symstring, ce_staticmacro, ce_inspectors, ce_editoroptions, ce_dockoptions, ce_symstring, ce_staticmacro, ce_inspectors, ce_editoroptions, ce_dockoptions,
ce_shortcutseditor, ce_mru, ce_processes, ce_dubproject, ce_dialogs, ce_shortcutseditor, ce_mru, ce_processes, ce_dubproject, ce_dialogs,
ce_dubprojeditor, ce_gdb, ce_controls, ce_dfmt, ce_lcldragdrop; ce_dubprojeditor, ce_controls, ce_dfmt, ce_lcldragdrop;
{$R *.res} {$R *.res}

View File

@ -76,10 +76,39 @@ const
serverName = 'dcd-server' + exeExt; serverName = 'dcd-server' + exeExt;
optsname = 'dcdoptions.txt'; optsname = 'dcdoptions.txt';
function checkDcdSocket: boolean;
var
str: string;
begin
sleep(100);
// nix/osx: the file might exists from a previous session that crashed
// however the 100 ms might be enough for DCD to initializes
{$IFDEF LINUX}
str := sysutils.GetEnvironmentVariable('XDG_RUNTIME_DIR');
if (str + DirectorySeparator + 'dcd.socket').fileExists then
exit(true);
str := sysutils.GetEnvironmentVariable('UID');
if ('/tmp/dcd-' + str + '.socket').fileExists then
exit(true);
{$ENDIF}
{$IFDEF DARWIN}
str := sysutils.GetEnvironmentVariable('UID');
if ('/var/tmp/dcd-' + str + '.socket').fileExists then
exit(true);
{$ENDIF}
//windows: just hope that the 100 ms were enough
{$IFDEF WINDOWS}
exit(true);
{$ENDIF}
exit(false);
end;
{$REGION Standard Comp/Obj------------------------------------------------------} {$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEDcdWrapper.create(aOwner: TComponent); constructor TCEDcdWrapper.create(aOwner: TComponent);
var var
fname: string; fname: string;
i: integer = 0;
begin begin
inherited; inherited;
// //
@ -113,7 +142,12 @@ begin
if fServer.isNotNil then if fServer.isNotNil then
begin begin
fServer.Execute; fServer.Execute;
sleep(20); while true do
begin
if (i = 10) or checkDcdSocket then
break;
i += 1;
end;
end; end;
updateServerlistening; updateServerlistening;
// //
@ -238,13 +272,7 @@ begin
fClient.Parameters.Clear; fClient.Parameters.Clear;
fClient.Parameters.Add('--shutdown'); fClient.Parameters.Add('--shutdown');
fClient.Execute; fClient.Execute;
{$IFDEF LINUX} sleep(500);
fClient.Terminate(0);
fServer.Terminate(0);
{$ENDIF}
{$IFDEF DARWIN}
//
{$ENDIF}
end; end;
procedure TCEDcdWrapper.waitClient; procedure TCEDcdWrapper.waitClient;