Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 482
  • Last Modified:

Server detects crashed COM clients for clean shutdown... How?

Hi,

I am working on a project that involves COM/DCOM client/server type coding. I am not the most experienced COM developer, so please excuse me if this is a dumb question!

My problem is this:

I have a client (console) which makes a connection to a server (.exe service module). The server starts running and everything is fine. Another console starts running, incrementing the servers reference count. Now one console crashes, and I mean total unclean crash, when the other console shuts down, the server remains running. It still has a reference count from the crashed client, but this will never be released.

I am looking for some way of finding out, from inside the server, that the client is no longer available. For example, when a reference is released, the server checks to ensure there is at least 1 client still actively connected, i.e. it is still running. If there is no-one but reference counts remain, it assumes some clients have crashed and it self-destructs.

Our servers all have pump threads in them, and the only possibilty I have right now is to have an event interface with a Test() method in it. All clients implement this interface, and simply respond to the Test() event with a "return S_OK". Periodically the server fires the Test() event to all connections, if it does not receive a S_OK return it concludes the client is gone.

However, I am looking for a cleaner solution, preferably without requiring any special coding or participation from the client.

Does anybody out there have any smart ideas?

Many thankx in advance,
Mark
0
mh2
Asked:
mh2
  • 3
  • 3
  • 3
  • +1
1 Solution
 
AlexVirochovskyCommented:
As I know, standart way is using
IObjectExporter::SimplePing Method, that makes exectly, what you describes: send test to Client, and ,if client dasn't react, diminish Reference Number,client is gone.
See more detailes in http://www.graphcomp.com/info/specs/com/dcomspec.txt
0
 
gurukg102498Commented:
First how did you identify that your Server is CRASHED ?
Did you get any General Protection Fault error saying Memory Read zero.
Pls let me know this.
0
 
mh2Author Commented:
Hi all,

Firslty, gurukg, it is not the server thats crashing, but the client. The problem is not the fact that the client crashes ( IRL it was a GPF, some buffer overrun, but this is irrelevant ), but that this leaves the server hanging and unable to shutdown. In my simple test console, I simply kill it using the "End Process" in NT task manager.

Alex, the IObjectExporter sounds exactly what I am needing. I found a newer ( 1998 ) version of the same draft in MSDN. However, I find the MSDN very lacking in documenting this. I am not exactly sure what I must do to implement this. Also, when searching the msdev directory, the word IObjectExporter cannot be found, nor can the OBJEX.IDL be found. You wouldn't by any chance know of any links to samples that use this mechanism would you?

Thank you very much for your time.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
mh2Author Commented:
Hi,

I have also asked the same question on a newsgroup, please do not be offended if you see my posting there. I do use the IObjectExporter interface I will give you the points.

Thankx,
Mark
0
 
AlexVirochovskyCommented:
0
 
gseryakovCommented:
Alex,

    Could you please describe the using of IObjectExporter in detail. I am asking because of the methods of this interface are described as being called from _client_ side. May be there is a way to read pinged/unpinged state? Is it going to work in local calls as well, not via DCOM?

    My ways of solving this problem are:
1) Transform your outproc COM server to MTS package. The reference count from crashed client will be removed by MTS timeout.
2) If you want better timing control, you could inplement 'heartbeat' interface on _client_ side. Client should register this interface on server, server should chech presence of this client and decrease counter if the cliend disappeared.

GS
0
 
gurukg102498Commented:
Alex,
Can it used for determining Server side CRASH also ?

Mh,

Are the clients are trying to do Simultaneous actions ?

0
 
AlexVirochovskyCommented:
to gurukg:
>>Can it used for determining Server side CRASH also ?
No, it is specific for solve Client crasch.
>>Could you please describe the using of IObjectExporter in detail.
See links in my comment
>>IObjectExporter is old name, new name is IOXIDResolver
...
>>Is it going to work in local calls as well, not via DCOM?
No, I think it is DCOM specific.

About your way: it is possible, but for me better use
something standart and not invent a wheel. But it is depends from you target. May be in your situation it is
better way, that standart.

   
0
 
gseryakovCommented:
Everybody:

Does anybody know how to send DCOM ping from server to client (AlexVirochovsky's suggestion)? Does anybody know how to check pinging status on server side? Does anybody know how to change the sittings of 3 pings * 2 minute?

My understanding is that DCOM pinging & GC is pretty much hardcoded and not so easy to intercept.

GS
0
 
mh2Author Commented:
Hi,

Thank you all for your comments.

From my research, it appears that these interfaces are in fact implemented in the DCOM wire-protocol itself, i.e the bottom layer. This pinging is done automatically, and is part of the DCOM garbage collection mechanism.

Here is a link to an another article I found:
DCOM and CORBA, Side By Side, Layer By Layer:
http://research.microsoft.com/~ymwang/papers/HTML/DCOMnCORBA/S.html

I still have more issues regarding server shutdowns, but this is a seperate issue ( forcing a shutdown via something like service manager ), so I have posted another question.

Thankx again,
Mark
0
 
gurukg102498Commented:
Mark,
Could you tell us the question on Server Crash / shutdown.
It's interesting to work with you all.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now