I have a program running in ubuntu Core. When i start it from command line type after ubuntu completly startup it work prefect fine. But if i put it in rc.local let it startup with system . It will crashed .
At first i suspect the reason is network haven't get ready . So i put ping testing command in rc.local before my program command line. From the log i got showing the network already been loaded.
So I write some log record in indy source code , i found it dead locked in when it using readLn to read html content from server
here is the code from Idhttp.pas 's TIdCustomeHttp class
ConnectToHost(Request, Response);
// Workaround for servers wich respond with 100 Continue on GET and HEAD
// This workaround is just for temporary use until we have final HTTP 1.1
// realisation. HTTP 1.1 is ongoing because of all the buggy and conflicting servers.
repeat
Response.ResponseText := IOHandler.ReadLn; ->This is the line deadLocked
SysLog.Info(Response.ResponseText);
FHTTPProto.RetrieveHeaders(MaxHeaderLines);
ProcessCookies(Request, Response);
until Response.ResponseCode <> 100;
case FHTTPProto.ProcessResponse(AIgnoreReplies) of
wnAuthRequest:
begin
Request.URL := AURL;
end;
wnReadAndGo:
begin
And from the log files i found readln after some sub calling ,finally it stop at this function
class function TIdSocketListUnix.FDSelect(AReadSet, AWriteSet, AExceptSet: PFDSet;
const ATimeout: Integer): Integer;
var
LTime: TTimeVal;
LTimePtr: PTimeVal;
begin
if ATimeout = IdTimeoutInfinite then begin
LTimePtr := nil;
end else begin
LTime.tv_sec := ATimeout div 1000;
LTime.tv_usec := (ATimeout mod 1000) * 1000;
LTimePtr := @LTime;
end;
SysLog.Info('fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr)');
Result := fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr); ->>> this is the line really dead locked
SysLog.Info('After fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr):'+inttostr(Result));
end;
From the log below you can see the have 'fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr) ' string loged . but no after.
................
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:400 Result := CheckIsReadable(AMSec);
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:400 EIdConnClosedGracefully.IfFalse(HandleAllocated, RSConnectionClosedGracefully);
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:Result := FReadSocketList.SelectRead(ATimeOut);TIdSocketListUnix Unit:IdStackUnix
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:Before TIdSocketListUnix.SelectRead Lock
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:After TIdSocketListUnix.SelectRead Lock
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr)
Could you give me some suggestion why the select function which work fine in console using comand line but dead locked at rc.local !
thanks a lot!