Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-05

Is THostResolver creating a thread?

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

A friend from Brazil found a small problem in "resolve" unit.

Before execute the test:

http://imagebin.org/256886

After execute the test:

http://imagebin.org/256887

And the test is:

procedure TForm1.Button1Click(Sender : TObject);
begin
  with TInetSocket.Create('www.google.com', 80) do
  try
  finally
    Free;
  end;
end;

After debug the TInetSocket class, the problem continues in:

procedure TForm1.Button1Click(Sender : TObject);
begin
 with THostResolver.Create(nil) do
  try
    if not NameLookup('www.google.com') then
      raise Exception.Create('não resolvido');
  finally
    Free;
  end;
end;

And finally, you can reproduce it with:

uses
  resolve, winsock;
procedure TForm1.Button1Click(Sender: TObject);
var
  FHostEntry: PHostEnt;
begin
  FHostEntry := gethostbyname('www.google.com.br');
end;

But, if in code above I undeclare the "resolve" unit, I got only one thread (threads = 1).

Is this a bug?

Thank you!

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to silvioprog

Oops,

2013/5/8 silvioprog

Show quoted text 11 lines
[...] uses resolve, winsock; procedure TForm1.Button1Click(Sender: TObject); var FHostEntry: PHostEnt; begin FHostEntry := gethostbyname('www.google.com.br'); end;

... gethostbyname('www.google.com') ...

Silvio Clécio My public projects - github.com/silvioprog
Michael Van Canneyt
to silvioprog
silvioprog wrote 16 lines
Oops, 2013/5/8 silvioprog [...] uses   resolve, winsock; procedure TForm1.Button1Click(Sender: TObject); var   FHostEntry: PHostEnt; begin   FHostEntry := gethostbyname('www.google.com.br'); end; ... gethostbyname('www.google.com') ...

The resolver or netdb units do not create threads by themselves.

But the windows Winsock routines may create threads (I would expect this), and these may show up in your process manager.

Michael.

silvioprog
to Michael Van Canneyt

2013/5/8 Michael Van Canneyt

Show quoted text 26 lines
On Wed, 8 May 2013, silvioprog wrote: > Oops, > > 2013/5/8 silvioprog > [...] > uses > resolve, winsock; > > procedure TForm1.Button1Click(Sender: TObject); > var > FHostEntry: PHostEnt; > begin > FHostEntry := gethostbyname('www.google.com.**br<http://www.google.com.br> > '); > end; > > ... gethostbyname('www.google.com'**) ... > The resolver or netdb units do not create threads by themselves. But the windows Winsock routines may create threads (I would expect this), and these may show up in your process manager. Michael.

But my project will always have a thread that is never released? Even when I freed my objects, that thread is still there.

Well, if this is done by the Windows API, I think we have nothing to do hehe...

Silvio Clécio My public projects - github.com/silvioprog
Zaher Dirkey
to silvioprog

Maybe it use the thread again, try many requests if there is more threads?

silvioprog wrote 44 lines
2013/5/8 Michael Van Canneyt > On Wed, 8 May 2013, silvioprog wrote: > >> Oops, >> >> 2013/5/8 silvioprog >> [...] >> uses >> resolve, winsock; >> >> procedure TForm1.Button1Click(Sender: TObject); >> var >> FHostEntry: PHostEnt; >> begin >> FHostEntry := gethostbyname('www.google.com.**br<http://www.google.com.br> >> '); >> end; >> >> ... gethostbyname('www.google.com'**) ... >> > > The resolver or netdb units do not create threads by themselves. > > But the windows Winsock routines may create threads (I would expect > this), and these may show up in your process manager. > > Michael. But my project will always have a thread that is never released? Even when I freed my objects, that thread is still there. Well, if this is done by the Windows API, I think we have nothing to do hehe... -- Silvio Clécio My public projects - github.com/silvioprog _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
I am using last revision of Lazarus, FPC 2.6 on Windows XP SP3 Best Regards Zaher Dirkey
silvioprog
to Zaher Dirkey

2013/5/8 Zaher Dirkey

Maybe it use the thread again, try many requests if there is more threads?

It keep only one thread. :)

Sorry Michael, Zaher and friends. A friend tested it in Delphi on Window XP and it's same to Free Pascal.

Silvio Clécio My public projects - github.com/silvioprog