안녕하세요.
지문인식서버용 프로그램이 있는데,
불규칙하게 CPU점유율을 높이며, 서버의 CPU팬이 큰소음을 내고 있습니다.
원인은 지문인식검색 부분의 프로세스가 그렇게 하는 것을 보여집니다.
아래 코드 부분은 문제가 되고 있는 지문인식검색 부분의 프로세스입니다.
문제점을 진단해 주셨으면 고맙겠습니다.
procedure TTCPServer.FormCreate(Sender: TObject);
var
i, x: integer;
lbl_top, lbl_left: integer;
led_top, led_left: integer;
appDir: string;
begin
objNBioBSP := CreateOleObject('NBioBSPCOM.NBioBSP');
objDevice := objNBioBSP.Device;
objExtraction := objNBioBSP.Extraction;
objNSearch := objNBioBSP.NSearch;
left:= 580;
top:= 80;
IdTCPServer.MaxConnections:= maxConnections;
appDir:= extractFilePath(application.exename);
setLength(ledConnected,maxConnections);
setLength(lblConIp,maxConnections);
led_top := Lb2_0.Top + 5;
led_left := Lb2_0.left + Lb2_0.width + 5;
lbl_top := Lb2_0.Top;
lbl_left := Lb2_0.left + Lb2_0.width + 5 + 20 + 10;
for i:= 0 to (maxConnections - 1) do begin
ledConnected[i] := TShape.create(panel1);
lblConIp[i] := TLabel.create(panel1);
with ledConnected[i] do begin
parent:= panel1;
height:= 8;
width:= 20;
top:= led_top; led_top := led_top + 16;
left:= led_left;
brush.color:= clRed;
end; { do with ledConnected[i] }
with lblConIp[i] do begin
parent:= panel1;
height:= 17;
width:= 65;
top:= lbl_top; lbl_top := lbl_top + 16;
left:= lbl_left;
font.color:= clBlue;
caption:= 'Free';
end; { do with edtConIp[i] }
end; { for i:= 0 to (maxConnections - 1) }
timer1.enabled:= true;
end; { FORM CREATE }
procedure TTCPServer.Timer1Timer(Sender: TObject);
begin
timer1.enabled:= false;
IdTCPServer.DefaultPort := 10001;
IdTCPServer.Active:= true;
ledListening.Brush.color:= clLime;
end; { TIMER1 TIMER }
procedure TTCPServer.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
idTcpServer.Active:= false;
ledListening.Brush.Color:= clRed;
application.processMessages;
canClose:= true;
end; { FORM CLOSE QUERY }
procedure TTCPServer.btnExitClick(Sender: TObject);
begin
close;
end; { BTN EXIT CLICK }
procedure TTCPServer.IdTCPServerExecute(AThread: TIdPeerThread);
var
connected: boolean;
line: string;
connectionNumber: integer;
connect_IP:string;
Finger_data : wideString;
member_no: string;
return_cd: string;
proc_gb: string;
memo_cnt: integer;
begin
memo_cnt := 0;
connectionNumber:= 0;
while (ledConnected[connectionNumber].Brush.Color = clLime) do
inc(connectionNumber);
connected:= true;
while connected do begin
try
line:= AThread.connection.ReadLn;
if line <> '' then
begin
connect_IP:= Trim(LeftStr(line,15)); // Data 구분 IP
proc_gb := MidStr(line,16,1); // Data 구분 Proc_gb
if proc_gb ='S' then
begin
Finger_data:= RightStr(line,Length(line)-16); // Data 구분 Finger_data
end;
if proc_gb ='N' then
begin
member_no := MidStr(line,17,8); // Data 구분 Proc_gb
Finger_data:= RightStr(line,Length(line)-24); // Data 구분 Finger_data
end;
memo1.Lines.add(format('[%d] %s',[connectionNumber, connect_IP + ' > ' + ' Call eNSearch'])); // -> 이 부분 다음에 CPU점유율이 올라갑니다.
Fingerprint_auth_proc(proc_gb,Finger_data,member_no,return_cd,connect_IP,connectionNumber);
if proc_gb ='S' then
begin
memo1.Lines.add(format('[%d] %s',[connectionNumber,connect_IP + ' > ' + ' Search Member_no = ' + member_no + ' Error_cd = ' + return_cd]));
end; {If//end}
if proc_gb ='N' then
begin
member_no:='';
memo1.Lines.add(format('[%d] %s',[connectionNumber,connect_IP + ' > ' + ' Add Member_no = ' + member_no + ' Error_cd = ' + return_cd]));
end;
AThread.connection.WriteLn(member_no+'$'+return_cd);
ledConnected[connectionNumber].Brush.Color:= clLime; //2006-04-04
lblConIp[connectionNumber].Caption := connect_IP; //2006-03-30
end;
if (ansiUpperCase(line) = 'BYE') or (ansiUpperCase(line) = 'QUIT') then
begin
AThread.Connection.Disconnect;
showmessage('Disconnect');
connected:= false;
end; { if (ansiUpperCase(line) = 'BYE') or (ansiUpperCase(line) = 'QUIT') }
except
connected:= false;
end; { try/except }
end; { do while connected }
ledConnected[connectionNumber].Brush.Color:= clRed; { show that we've disconnected [!] }
lblConIp[connectionNumber].Caption := 'Free'; //2006-03-30
end; { ID TCP SERVER EXECUTE }
procedure TTCPServer.Fingerprint_auth_proc(proc_gb: string; Finger_data: WideString; var member_no: string; var return_cd:string; connect_IP:string;connectionNumber:integer) ;
var
wsFing_Key: Widestring;
nUserID: integer;
begin
// 지문인증(검색)
if proc_gb = 'S' then
begin
memo1.Lines.add(format('[%d] %s',[connectionNumber,connect_IP + ' > ' + ' Search']));
objNSearch.IdentifyUser(Finger_data, 5);
if objNSearch.ErrorCode = 0 then
Begin
member_no := Formatfloat('00000000', objNSearch.UserID);
return_cd := '0';
end
else
Begin
member_no := '';
return_cd := Formatfloat('000', objNSearch.ErrorCode);
end; //if~else
memo1.Lines.add(format('[%d] %s',[connectionNumber,connect_IP + ' > ' + ' END of eNSearch']));
end;
//지문추가(회원신규) //회원번호 검색하여 DB에 추가
if proc_gb = 'N' then
begin
memo1.Lines.add(format('[%d] %s',[connectionNumber,connect_IP + ' > ' + ' Add']));
wsFing_Key := Finger_data;
nUserID := StrToInt(member_no);
objNSearch.AddFIR(wsFing_Key, nUserID);
if objNSearch.ErrorCode = 0 then
begin
// Success
return_cd := '0';
end
else
begin
// Failed
member_no:='';
return_cd := Formatfloat('000', objNSearch.ErrorCode);
end; {if~else}
// Application.ProcessMessages;
ADOQuery1.close;
memo1.Lines.add(format('[%d] %s',[connectionNumber,connect_IP + ' > ' + ' END of eNSearch']));
end;
end;
procedure TTCPServer.Img_btn_ExitClick(Sender: TObject);
begin
close;
end;
end. {*}