| www.delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-developers-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-developers-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin-developers/> |
| List-Post: | <mailto:cygwin-developers AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-developers-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-developers-owner AT cygwin DOT com |
| Delivered-To: | mailing list cygwin-developers AT cygwin DOT com |
| Date: | Wed, 12 Jun 2002 21:35:49 +0400 |
| From: | egor duda <deo AT logos-m DOT ru> |
| Reply-To: | egor duda <cygwin-developers AT cygwin DOT com> |
| Organization: | deo |
| X-Priority: | 3 (Normal) |
| Message-ID: | <17816532682.20020612213549@logos-m.ru> |
| To: | "Conrad Scott" <Conrad DOT Scott AT dsl DOT pipex DOT com> |
| CC: | cygwin-developers AT cygwin DOT com |
| Subject: | Re: DuplicateHandle() question |
| In-Reply-To: | <00f201c21234$4e19d3b0$6132bc3e@BABEL> |
| References: | <091e01c2120f$25e50290$6132bc3e AT BABEL> |
| <1149904301 DOT 20020612194520 AT logos-m DOT ru> <00f201c21234$4e19d3b0$6132bc3e AT BABEL> | |
| MIME-Version: | 1.0 |
Hi!
Wednesday, 12 June, 2002 Conrad Scott Conrad DOT Scott AT dsl DOT pipex DOT com wrote:
>> I don't quite understand why server would want client to discard some
>> handle. Can you describe step-by-step scenario when it's needed? Do
>> you have shmctl(..., IPC_RMID, ...) in mind?
CS> Not shmctl(2) but shmget(2): when creating and accessing shm segments for a
CS> client, the cygserver calls CreateFileMapping() to create the memory areas
CS> and then uses DuplicateHandle() on the resulting handles to create handles
CS> for the client (in client process) to these file mappings. The problem then
CS> arises that the sever can fail having duplicated some but not all of the
CS> handles for the client, i.e. it's just an error cleanup question: I'm not
CS> looking to have the server arbitrarily close client handles.
CS> AIUI at that point the handles are valid in the client process but the
CS> server can't close them, i.e. the client has to close them. Is that true or
CS> is there some way for the server to close them (i.e. a "close in other
CS> process" function)? I assume not.
You are creating some object in client process' address space. This
object contains some handles. Some are possibly created by client
(imagine that we want to serialize access to our object and create a
mutex for this), and some are "pushed in" by server. I.e. on the
client side we have something like
shmget (...)
{
...
handle1 = handle2 = ... = 0;
handle1 = CreateMutex (...);
if (!handle1) goto failure;
handle2 = GetHandleFromServer (...);
if (!handle2) goto failure;
...
return NO_ERROR;
failure:
// cleanup
if (handle1) CloseHandle (handle1);
if (handle2) CloseHandle (handle2);
...
return ERROR;
}
All server has to do is to return valid handle on success and 0 on
error. It's up to client to interpret the results. Or you can make
server return all handles in some structure so that client will have
to call server only once. But then again, all server has to do is to
fill this structure and it's up to client to discard all valid handles
if at least one of returned handles is 0.
Egor. mailto:deo AT logos-m DOT ru ICQ 5165414 FidoNet 2:5020/496.19
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |