discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

implicit NSRunLoop invocations and reentrancy


From: David Ayers
Subject: implicit NSRunLoop invocations and reentrancy
Date: Tue, 24 Sep 2024 08:19:39 +0200
User-agent: Evolution 3.46.4-2

Hello!

we are developing a single threaded webserver application which
processes requests with NSRunLoop and most of the time everything runs
fine.  Yet once in while we want to use GNUstep methods, which happen
to run the default NSRunLoop implicitly.  Now that effectively requires
the web requests processing to be reentrant. But being an ObjC
application with all kinds of distributed state, this is prone to cause
havoc more often than not.  Let me try to illustrate:

Webserver request:
- find the Session stat, build all kinds of convenience infrastructure
and start processing...
- during processing call either
-- -[NSTask waitUntilExit]
-- +[NSFileHandle fileHandleAsClientAtAddress:service:protocol:]
-- +[NSURLConnection sendSynchronousRequest:returningResponse:error:]
and while these methods "wait" for IO in the default NSRunLoop new web
server requests get processed before the current requests can be
served.  This will clobber the convenience infrastructure of the
current request.

This of behavior is not specific to a webserver application.  It's
something any NSRunLoop based application may have to deal with.  So
I'm wondering, what is the software design pattern, that I am missing,
to deal with NSRunLoop causing this implicit reentrancy.  Are we just
wrong in distributing that no reentrant convenience infrastructure in a
an a web of objects (especially in times where everyone else is
programming for containers).

Or wouldn't the correct solution be that all these implicit run loop
invocations should use local run loops instead of the default run loop?
But I guess that defeats purpose of using the the run loop at all,
since the point is not to block the application processing while
waiting.

I guess what I'm looking for is way to configure the run loop to
refrain from optimizing for performance and simply wait for those
implicit calls to finish without processing any unrelated requests.

Thanks!
David

PS: Please keep me cc:d

-- 
David Ayers

Supporting:
Free Software Foundation Europe        []   (http://www.fsfe.org)
Become a supporter of the FSFE!      [][][] 
Your donation powers important work!   ||   (http://fsfe.org/donate)

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]