[CDRIVER-609] Stream handlers need to differentiate between closing a stream due to error or normal cleanup Created: 07/Apr/15  Updated: 07/Oct/15  Resolved: 08/Apr/15

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.1.4
Fix Version/s: 1.2-beta0

Type: Bug Priority: Major - P3
Reporter: Hannes Magnusson Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to PHPC-231 Manager instances should not free str... Closed

 Description   

The stream handler expose a way to destruct (close (if needed) and free) a stream resource – but that doesn't tell you why it is requested at all.

We need a way to differentiate between closing a stream due to error (e.g. connection failure, replicaset reconfigured without that node, invalid reply from server, ... ..) vs closing the stream due to normal cleanup routines (mongoc_destroy(), ...).

The handling of these two cases is vastly different for language bindings, as in the first case the stream really needs to be killed dead - while in the second case it does not. The language binding may want to keep it around for other purposes – or resume it for next client.

This is especially important for the PHP bindings as we implement "persistent streams" across requests (and manager – and background sdam checks).
We don't want to destroy these stream when destroying a client (which happens after every request) as the next client (for the next request) will be requesting the same stream very shortly.



 Comments   
Comment by Githook User [ 07/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: Merge branch 'bjori-CDRIVER-609' into 1.2.0-dev

Comment by Githook User [ 07/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: Merge branch 'bjori-CDRIVER-609' into 1.2.0-dev

Comment by Githook User [ 07/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: Merge branch 'bjori-CDRIVER-609' into 1.2.0-dev

Comment by Githook User [ 07/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-609: Differenciate between a failed stream, and cleanup/destroy

This adds a new `failed` handler to the mongoc_stream_t, along with
mongoc_stream_failed().

The failed handler shall be called when the stream truely needs to be
destroyed (due to errors, removal from topology, etc etc).
The destroy handler shall be called during normal _destroy() routines,
like mongoc_destroy().

By default, for BC, if no failed handler is provided we will fallback
and call the `destroy` handler.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/1926413b45390887431bbfb0380631153c886b74

Comment by Githook User [ 08/Apr/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: Merge branch 'bjori-CDRIVER-609' into 1.2.0-dev

Comment by Githook User [ 08/Apr/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: Merge branch 'bjori-CDRIVER-609' into 1.2.0-dev

Comment by Githook User [ 08/Apr/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: Merge branch 'bjori-CDRIVER-609' into 1.2.0-dev

Comment by Githook User [ 08/Apr/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-609: Differenciate between a failed stream, and cleanup/destroy

This adds a new `failed` handler to the mongoc_stream_t, along with
mongoc_stream_failed().

The failed handler shall be called when the stream truely needs to be
destroyed (due to errors, removal from topology, etc etc).
The destroy handler shall be called during normal _destroy() routines,
like mongoc_destroy().

By default, for BC, if no failed handler is provided we will fallback
and call the `destroy` handler.
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/1926413b45390887431bbfb0380631153c886b74

Comment by Hannes Magnusson [ 07/Apr/15 ]

https://github.com/mongodb/mongo-c-driver/pull/215

Generated at Wed Feb 07 21:10:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.