Skip to content

PHPC-600: Use mongoc_client_get_server_descriptions() to get Manager's Servers #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2016

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Apr 7, 2016

@derickr
Copy link
Contributor

derickr commented Apr 8, 2016

I don't think this is enough. There is another intern->client->topology->description.servers in the debug info that needs to use mongoc_client_get_server_descriptions() too. Just like I changed for https://jira.mongodb.org/browse/HHVM-196 (which incidentally, has the other location in the title): https://github.com/mongodb/mongo-hhvm-driver/pull/78/files#diff-dcd03e4e31145855552adc282c2fb08cL474

After make that change as well, you will see tests/manager/manager-var-dump-001.phpt fail, as there is a dummy broken server in the cluster output.

add_next_index_zval(return_value, obj);
#endif
}

mongoc_server_descriptions_destroy_all(sds, n);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derickr: I believe mongodb/mongo-hhvm-driver#78 was missing this. Can you confirm if you're leaking memory via the array returned from mongoc_client_get_server_descriptions()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened HHVM-215 to track this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmikola jmikola changed the title PHPC-600: Use mongoc_client_get_server_descriptions() in Manager::getServers() PHPC-600: Use mongoc_client_get_server_descriptions() to get Manager's Servers Apr 11, 2016
@jmikola jmikola force-pushed the phpc-600 branch 2 times, most recently from ee91a1f to 165ed2b Compare April 11, 2016 23:56

phongo_server_init(obj, intern->client, sd->id TSRMLS_CC);
MAKE_STD_ZVAL(obj);
phongo_server_init(obj, intern->client, mongoc_server_description_id(sds[i]) TSRMLS_CC);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need the method call mongoc_server_description_id(sds[i]) here? I believe, sds[i]->id should be safe too? As far as I know, the server_description_t type is public. Otherwise php_phongo_server_to_zval would not work at all either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mongoc-server-description.h only defines:

typedef struct _mongoc_server_description_t mongoc_server_description_t;

_mongoc_server_description_t is defined in mongoc-server-description-private.h. I noticed that Manager.c was still including mongoc-server-description-private.h, so I've removed it and amended the commit. Any headers I don't catch in these PRs will ultimately be removed in PHPC-665, which should be the final test that we're abiding the public API.

FYI: php_phongo_server_to_zval() is being migrated to the public API in #291 for PHPC-606.

@derickr
Copy link
Contributor

derickr commented Apr 14, 2016

LGTM

@jmikola jmikola merged commit ae801ee into mongodb:master Apr 14, 2016
jmikola added a commit that referenced this pull request Apr 14, 2016
@jmikola jmikola deleted the phpc-600 branch April 14, 2016 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants