Solved

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

Posted on 2001-09-04
11
461 Views
Last Modified: 2007-11-27
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
Comment
Question by:mh2
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 300 total points
ID: 6452834
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
 

Expert Comment

by:gurukg102498
ID: 6455446
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
 
LVL 3

Author Comment

by:mh2
ID: 6455790
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
 
LVL 3

Author Comment

by:mh2
ID: 6455887
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
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6456339
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Expert Comment

by:gseryakov
ID: 6457346
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
 

Expert Comment

by:gurukg102498
ID: 6459435
Alex,
Can it used for determining Server side CRASH also ?

Mh,

Are the clients are trying to do Simultaneous actions ?

0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6459542
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
 

Expert Comment

by:gseryakov
ID: 6460716
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
 
LVL 3

Author Comment

by:mh2
ID: 6463089
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
 

Expert Comment

by:gurukg102498
ID: 6466189
Mark,
Could you tell us the question on Server Crash / shutdown.
It's interesting to work with you all.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now