OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Phil Reynolds (preynoldsRIDGEWAYSYSTEMS.COM)
Date: Wed Feb 06 2002 - 07:53:44 CST

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    Try thinking about how it would work if the client and server were local
    i.e. no DCOM or other magic going on

    The server gets a record set from somewhere (RefCount == 1)
    It copies the pointer to the [out] param and AddRef()s it (RefCount == 2)
    It Releases it's local copy of the pointer (RefCount == 1) and returns.
    Client uses record set... and Finally Release()s it (RefCount == 0) record
    set goes away

    Now take a blind leap of faith and assume that DCOM knows what it is doing
    and that the above still holds. DCOM will make sure that after the record
    set has been transferred to the client, the client has 1 reference to it and
    the server has none. If the transfer is by physical copy (i.e. Marshal By
    Value (MBV)) then DCOM will Release() the original object after the copy has
    been made and AddRef()ed. If the transfer is just passing an interface
    pointer to the original then DCOM will create the relevant proxy and stub
    which will handle the remoting of the clients Release().

    > -----Original Message-----
    > From: Pete Davis [mailto:pdavisQUETEL.COM]
    > Sent: 06 February 2002 13:33
    > To: DCOMDISCUSS.MICROSOFT.COM
    > Subject: Re: [DCOM] Page Swapping
    >
    >
    > Actually, this is exactly what we do, but can we do a
    > pLocalRecordset->Release() without releasing **ppRecSet?
    >
    > Pete
    > ----- Original Message -----
    > From: "Jonas Blunck TACMa" <jobuTAC.SE>
    > To: <DCOMDISCUSS.MICROSOFT.COM>
    > Sent: Wednesday, February 06, 2002 8:26 AM
    > Subject: Re: Page Swapping
    >
    >
    > > What about doing this:
    > >
    > > HRESULT Amethod(Idispatch** ppRecSet)
    > > {
    > > *ppRecSet = pLocalRecordset; // ado recordset
    > > (*ppRecSet)->AddRef();
    > >
    > > return S_OK;
    > > }
    > >
    > > The recordset is AddRef'ed and can be released when the
    > client is done
    > with
    > > it. This also confirms with the COM reference couting rules, which
    > > effectively state that out-parameters should be AddRef'ed.
    > >
    > > // B
    > >
    > >
    > > -----Original Message-----
    > > From: Pete Davis [mailto:pdavisQUETEL.COM]
    > > Sent: den 6 februari 2002 14:27
    > > To: DCOMDISCUSS.MICROSOFT.COM
    > > Subject: Re: Page Swapping
    > >
    > >
    > > Okay, it works something like this:
    > >
    > > HRESULT AMethod(/*[out]*/ IDispatch **ppRecSet)
    > > {
    > > ...
    > > Get an ADO recordset
    > > ...
    > >
    > > *ppRecSet = (IDispatch*) pLocalRecordset;
    > >
    > > return S_OK
    > > }
    > >
    > > Okay, at the time when we execute return S_OK, the
    > pLocalRecordset needs
    > to
    > > have a reference count of 1, otherwise the client will
    > receive an invalid
    > > recordset.
    > >
    > > So, there's no way, at ths point, to release
    > pLocalRecordset. So instead,
    > > before calling return S_OK, we add pLocalRecordset to our garbage
    > collection
    > > list. The next time AMethod is called, the first thing we
    > do is go through
    > > the list and release any recordsets that are more than 2
    > minutes old.
    > >
    > > Does that make sense?
    > >
    > > Pete
    > >
    > > ----- Original Message -----
    > > From: "Jonas Blunck TACMa" <jobuTAC.SE>
    > > To: <DCOMDISCUSS.MICROSOFT.COM>
    > > Sent: Wednesday, February 06, 2002 8:09 AM
    > > Subject: Re: Page Swapping
    > >
    > > [snip]
    > > Had to delete the rest as the message got bounced for being
    > too long.
    > >
    > > ----------------------------------------------------------------
    > > Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    > > contains important info. Save time, search the archives at
    > > http://discuss.microsoft.com/archives/index.html . To unsubscribe,
    > > mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM
    > >
    > > ----------------------------------------------------------------
    > > Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    > > contains important info. Save time, search the archives at
    > > http://discuss.microsoft.com/archives/index.html .
    > > To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM
    > >
    >
    > ----------------------------------------------------------------
    > Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    > contains important info. Save time, search the archives at
    > http://discuss.microsoft.com/archives/index.html .
    > To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM
    >

    ----------------------------------------------------------------
    Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    contains important info. Save time, search the archives at
    http://discuss.microsoft.com/archives/index.html .
    To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM