.NET IpcChannel not reliably cleared correctly?

For some reason, after using IpcChannel and closing it, sometimes the named program remains open and a thread is waiting on it. I cannot do this on demand in a debugging environment, but it happens 5 to 10 times a day in our production environment. The bad effect this has is that it stops me from unloading the appdomain, since there is an infinite stream waiting endlessly on the named pipe (in the native method) ... in my code there is no frame in the freeze frame - this is internal. network thread. If I started the process handler and found a named channel descriptor that was left open and forced to close it, then everything becomes happy again, appdomain is unloaded in order. Maybe I'm doing something wrong since I didn’t work with IpcChannels a lot ... my server code is here: http://pastebin.com/f6e2583b9 , if someone wants to peek ... this works on a fully fixed Server2003 / .NET 2.0.

As a workaround, I think I will monitor every channel I created and then periodically check to make sure they are turned off properly, and then when unloading the appdomain I will force close any pipes that remain hanging .... can anyone Something to point me in the right direction, how can I do this? I know the name of the pipe .... but I'm not sure how to check if everything is open or how to close any existing descriptors ...

+4
source share
1 answer

Yes, I have seen this before. A similar situation can happen with IPC, when the client still has the IPC channel - the server will not be able to close and open it again, because it is already in use by the client.

To work around these issues, it is recommended that you use all the channels of the IPC server channel in the AppDomain child application. then, when you want to close it, you simply follow the usual "fine" procedures for closing the close () function, and then AppDomain Unload. it will destroy any abandoned.

it will remove any IPC related stuff and also hit the client in the head to clog the IPC channel;)

+1
source

Source: https://habr.com/ru/post/1301838/


All Articles