Solved

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

Posted on 2001-09-04
11
473 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

724 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