Solved

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

Posted on 2001-09-04
11
466 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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
 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

770 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