resetall?

Mark Waddingham mark at livecode.com
Mon Feb 21 13:37:38 EST 2022


On 2022-02-21 18:09, Mark Wieder via use-livecode wrote:
> On 2/21/22 08:57, Mark Waddingham via use-livecode wrote:
> 
>> If you want to brute force close all sockets then I suggest:
>> 
>> 
>>      repeat for each line i in the openSockets
>>        close socket i
>>      end repeat
>> 
>> :)
> 
> Yeah, that's what I'm doing now since resetall doesn't do anything
> useful. Displaying the opensockets after a resetall still shows the
> same sockets as before issuing the command.
> 
> And the repeat loop works maybe 50% of the time. It seems that maybe
> if I have an active blocking read on a socket it doesn't get closed.
> Could that be the case?

So I think there's something else going on in your scripts (or in the 
environment!) as from what I can see...

When `close socket` is performed, the socket is marked as `closing`, and 
`the openSockets` never includes sockets which are marked as `closing`.

The closing flag on a socket is only ever changed in two places - on 
socket creation/open, when it is set to false, and then on `close 
socket` where it is set to true.

Put another way - if you have done 'close socket i', then it is then it 
should be logically impossible for i to be in the openSockets 
immediately afterwards.

i.e. Based on my reading of the engine code:

   get line 1 of the openSockets
   close socket it
   put it is among the line of the openSockets

Will always put false.

Of course, it is possible after closing a socket, and if the event loop 
has run for a handler to have opened the same socket again (bearing in 
mind sockets are named for their address and port; unless an explicit 
tag is provided)...

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps



More information about the use-livecode mailing list