IBX:向 TIBControlAndQueryService.InternalServiceQuery 添加超时
我想在调用 TIBControlAndQueryServiceGetNextLine 时添加 isc_info_svc_timeout (1 秒)选项。我复制并修改了 IBServices,以类似的方式将 isc_info_svc_timeout 附加到 isc_info_svc_line 之后的 ServiceQueryParams,例如 ServiceStartAddParam (Value: Integer; param: Integer) ,但我收到错误消息“功能不支持”
编辑
首先我决定将超时添加到 InternalServiceQuery 而不是 GetNextLine 。其次,我将超时参数附加到 FQueryParams 中,但我不应该这样做。第三,超时参数在 isc_service_query 函数中拥有自己的位置,即第 4 和第 5 个位置(数据和数据指针的长度)。现在看起来它可以工作了,我的意思是没有“功能不支持”错误,但不幸的是它没有。调用 GetNextLine (调用 InternalServiceQuery)后,当没有数据发回时,我的应用程序会挂起并等待数据,就像超时参数不起作用。
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(PTimeout, 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
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(PTimeout, 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论