local files and the Qt QSocketNotifier

Platform: SuSE linux 5.3, egcs-1.1.2-pre2, libwww from the CVS
          checkout, Qt 2.x (from the CVS checkout)

I've figured out now that the "wild socket" messages I reported in
        http://lists.w3.org/Archives/Public/www-lib/1999JulSep/1064.html
        http://lists.w3.org/Archives/Public/www-lib/1999JulSep/1083.html
were caused by the QSocketNotifier class 
        http://www.troll.no/qt/qsocketnotifier.html
not supporting local files.

My "cure" was to make requests to local files be preemptive, ie. like
this:
    ...
    if (strncmp(url,"file:///",8) == 0) {
	HTRequest_setPreemptive(request, true);
	HTChunk* chunk = HTLoadToChunk(url,request);
	setChunk(this,url,chunk); // not handled by chunk_complete
    } else {
	HTChunk* chunk = HTLoadToChunk(url,request);
	HTRequest_setContext(request,chunk);
    }
    ...
(setChunk is also called from the "After" filter handling the
HT_LOADED status)

But this has the strange effect that files loaded by HTTP are handled
better than files loaded locally, by the GUI (which expects
asynchronous request/response operation)...:-/

I've looked at the code in FileEvent in HTFile.c:
                ...(line 562)
		if (HTEvent_isCallbacksRegistered()) {
		    if (!HTRequest_preemptive(request)) {
			if (!HTNet_preemptive(net)) {
			    HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n");
			    HTHost_register(HTNet_host(net), net, HTEvent_READ);
			} else if (!file->timer) {
			    HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n");
			    file->timer =
				HTTimer_new(NULL, ReturnEvent, file, 1, YES, NO);
			}
			return HT_OK;
		    }
		}
                ...(line 576)

If I can make the HTNet object of the request preemptive, and use the
timer somehow I might be able to get a request/response operation for
local files as well.

But there is no HTNet function for making it preemptive, like there is
for HTRequest.  Does that mean that it's not meant to be manually set
to be preemptive?  Or is there another way?

All hints and tips appreciated as always!


- Steinar

Received on Wednesday, 1 September 1999 11:02:53 UTC