IBX: add timeout to TIBControlAndQueryService.InternalServiceQuery
I would like to add isc_info_svc_timeout (1 second) option when calling TIBControlAndQueryServiceGetNextLine. I copied and modyfied IBServices to append isc_info_svc_timeout to ServiceQueryParams after isc_info_svc_line in similar way such as ServiceStartAddParam (Value: Integer; param: Integer) does, but im getting error message "feature not supported"
EDIT
First i decided to add timeout to InternalServiceQuery not GetNextLine. Second I was appending timeout param to FQueryParams which i shouldnt. Third the timeout param has its own place in isc_service_query function, 4 and 5 position (lengh of data and data pointer). Now it looks like its working, i mean NO "feature not supported" error but unfortunatelly it does not. After call to GetNextLine (which calls InternalServiceQuery) when there is no data to send back my app hangs and waits for data, like the timeout param has no effect.
procedure TIBCustomService.InternalServiceQuery;
function AddParam (Value: Integer; param: Integer): string;
begin
Result := Char(Param) +
PChar(@Value)[0] +
PChar(@Value)[1] +
PChar(@Value)[2] +
PChar(@Value)[3];
end;
var
FTimeout: string;
PTimeout: PChar;
FTimeoutLen: short;
begin
FTimeout := AddParam(1, isc_info_svc_timeout);
FTimeoutLen := Length(FTimeout);
PTimeout := nil;
IBAlloc(PTimeo开发者_如何学编程ut, 0, FTimeoutLen);
Move(FTimeout[1], PTimeout[0], FTimeoutLen);
FQuerySPBLength := Length(FQueryParams);
if FQuerySPBLength = 0 then
IBError(ibxeQueryParamsError, [nil]);
IBAlloc(FQuerySPB, 0, FQuerySPBLength);
Move(FQueryParams[1], FQuerySPB[0], FQuerySPBLength);
if (FOutputBuffer = nil) then
IBAlloc(FOutputBuffer, 0, FBufferSize);
try
if call(FGDSLibrary.isc_service_query(StatusVector, @FHandle, nil,
FTimeoutLen, PTimeout,
FQuerySPBLength, FQuerySPB,
FBufferSize, FOutputBuffer), False) > 0 then
begin
精彩评论