W3C home > Mailing lists > Public > www-lib@w3.org > April to June 2000

RE: Infinite Event Loop

From: Yovav Meydad <yovavm@contact.com>
Date: Sun, 16 Apr 2000 09:42:35 +0200
To: "'Joel DeYoung'" <joel@deyoung.net>
Cc: <www-lib@w3.org>
Message-ID: <000e01bfa777$558f8880$1c44a8c0@yovavm>
Joel,

I am using version 2.4.1 of htevtlst.c
Did this problem happened to you in a COM based application over NT too, or
was it a different platform / console app.
The reason I ask this is cause I have some filling it might be related to
the way COM manage all calls to an object through one thread.

Any idea ?

Yovav

~~~~~~~~~~~~~~~~~~~
yovavm@contact.com

Software Engineer
Contact Networks
www.contact.com
We Invite You to Make Contact!
~~~~~~~~~~~~~~~~~~~

-----Original Message-----
From: Joel DeYoung [mailto:joel@deyoung.net]
Sent: Thursday, April 13, 2000 8:26 PM
To: yovavm@contact.com
Subject: Re: Infinite Event Loop


What version of htevtlst.c do you have?  I had a similar problem with a
timeout causing an infinite loop, and this was apparently a bug that was
fixed since the last release.  The last release (5.2.8) had htevtlst.c
version 2.38.  I just replaced this with verion 2.41 of htevtlst.c and this
fixed the problem.

I hope this helps,
Joel


At 08:01 PM 4/13/00 +0200, you wrote:
>Hi,
>
>I have a GUI app, which makes a call to a COM object's method which should
>perform a file download from some URL.
>I have a C++ class which wraps some of libwww functions, and in the COM
>object's implementation I use an instance of this class in order to
actually
>perform the download.
>The implementation of the Download method is based on the Loadtofile sample
>of libwww.
>
>So, I implemented the DownloadFile method; the filters for Progress &
>Messages
>and a terminate handler which is an AFTER filter for the download request I
>create.
>
>Note:
>I use Win2K & DevStudio 6.0 sp3
>
>The problem :
>~~~~~~~~~~~
>After calling to HTLoadToFile, I enter the event loop.
>During the Dispatching of the message by the loop, a 2nd thread is created,
>Which in it the PROGRESS handler & Terminate handlers are done.
>But, after the terminate handler is finished, the context returns to the
>message loop of the GUI, instead to the 1st thread.
>After a while (several min.), some timeout occurs, and the event loop gets
>another message to handle.
>Since I have inserted in TerminateHandler a call to HTEventList_stopLoop(),
>the boolean flag of the loop set to 1, and the loop is stopped.
>After this, the context goes back to the COM object method, then I can
>continue checking the status etc.
>
>How can I cause the context to return to the 1st thread immediately after
>the TerminateHandler is done ? Why does it happen ?
>In all other samples of libwww including WinCom only 1 thread is created -
>why is this ?
>
>Here are some parts from the code:
>~~~~~~~~~~~~~~~~~~~~~~~
>1. The download method of the COM object:
>
>STDMETHODIMP CAutoUpgrader::DownloadUpgrade()
>{
>	// Some code to obtain the url, host, port, fileName
>	...
>
>	CRequester requester;
>	st = requester.RequestDownload(lpHost, iPort, const char *i_lpURL, const
>char *i_lpOutputFile
>
>	// Check download statu
>	if (!st)
>		// Error
>	return S_OK;
>}
>
>2. The requester is a C++ class, which wraps some libwww code:
>
>int CRequester::RequestDownload(const char *i_lpHost, int i_iPort, const
>char *i_lpURL, const char *i_lpOutputFile)
>{
>	// Create a request
>	HTRequest* pRequest = HTRequest_new();
>
>    	// register the Download Termination handler
>	HTRequest_addAfter(pRequest,TerminateHandler,NULL, NULL, HT_ALL,
>HT_FILTER_FIRST, YES);
>
>	// construct a string with full url
>	string strURL = createFullUrl(i_lpHost, i_iPort, i_lpURL);
>
>	// Download it
>	BOOL st = HTLoadToFile(strURL.c_str(), pRequest, i_lpOutputFile);
>
>        	// Go into the event loop...
>	HTEventList_newLoop();
>
>}
>
>3. I also implemented the filter for HT_A_PROGRESS and HT_A_MESSAGE,
>which posts messages to the GUI regarding progress & errors.
>
>4. In the TerminateHandler I perform:
>
>BOOL TerminateHandler(HTRequest * request, HTResponse * response, void *
>param, int status)
>
>	// cleanup the request & stop the event loop
>	HTRequest_delete(request);
>	HTEventList_stopLoop();
> 	return (status ? status : HT_OK);
>}
>
>Hope someone has the answer,
>
>thanks
>Yovav
>
>~~~~~~~~~~~~~~~~~~~
>yovavm@contact.com
>
>Software Engineer
>Contact Networks
>www.contact.com
>We Invite You to Make Contact!
>~~~~~~~~~~~~~~~~~~~
>
>

-----------------------
Joel DeYoung
Maple Ridge, BC, Canada
joel@deyoung.net
http://joel.deyoung.net
Received on Sunday, 16 April 2000 03:46:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:36 GMT