X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fgraph%2Fiterator.c;h=07eaa1fd146d42d8702c897ec6020bf0f95a46c1;hb=8cf27cc5e3f9c0ee7e1120ba0e0bd7f17d5a10ed;hp=70930bc75c1c68a54a3af5249a2d5dbb8683a22e;hpb=8f9d7550c162149e4cc7baf4456aa767d0020423;p=babeltrace.git diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 70930bc7..07eaa1fd 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -1550,6 +1550,32 @@ enum bt_notification_iterator_status ensure_queue_has_notifications( goto end; } + if (iterator->state == BT_NOTIFICATION_ITERATOR_STATE_FINALIZED || + iterator->state == BT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED) { + /* + * The user's "next" method, somehow, cancelled + * its own notification iterator. This can + * happen, for example, when the user's method + * removes the port on which there's the + * connection from which the iterator was + * created. In this case, said connection is + * ended, and all its notification iterators are + * finalized. + * + * Only bt_put() the returned notification if + * the status is + * BT_NOTIFICATION_ITERATOR_STATUS_OK because + * otherwise this field could be garbage. + */ + if (next_return.status == + BT_NOTIFICATION_ITERATOR_STATUS_OK) { + bt_put(next_return.notification); + } + + status = BT_NOTIFICATION_ITERATOR_STATUS_CANCELED; + goto end; + } + switch (next_return.status) { case BT_NOTIFICATION_ITERATOR_STATUS_END: ret = handle_end(iterator);