-
Notifications
You must be signed in to change notification settings - Fork 456
CDRIVER-5815 support disabling socket timeouts #2185
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
base: master
Are you sure you want to change the base?
Changes from 21 commits
2cf5adc
6ed9323
596727c
5432608
bb23cbd
5678eec
d4d1f45
4fb27cb
8c12d39
d9811a7
969fe26
6e1a6db
52c1672
6d0b809
f8056fd
2a458ef
2261cfd
93b32a8
dfac42d
3c59307
7f4a63c
34f63a5
6ff501c
f65bb76
fb8f40f
1773b8a
5314d22
4b7dce8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -36,10 +36,10 @@ struct _mongoc_stream_socket_t { | |||||
| static BSON_INLINE int64_t | ||||||
| get_expiration(int32_t timeout_msec) | ||||||
| { | ||||||
| if (timeout_msec < 0) { | ||||||
| return -1; | ||||||
| } else if (timeout_msec == 0) { | ||||||
| if (timeout_msec == MONGOC_SOCKET_TIMEOUT_IMMEDIATE) { | ||||||
| return 0; | ||||||
| } else if (timeout_msec <= 0) { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I expect this may change how mongoc_socket_t *sock = mongoc_socket_new(AF_INET, SOCK_STREAM, 0);
// Build address struct for localhost:27017:
struct sockaddr_in server_addr = {0};
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(27017);
server_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
ssize_t ok = mongoc_socket_connect(sock, (struct sockaddr *)&server_addr, sizeof(server_addr), -1);
ASSERT_CMPSSIZE_T(ok, ==, 0);
mongoc_stream_t *stream = mongoc_stream_socket_new(sock);
mongoc_iovec_t iov = {.iov_base = "foo", .iov_len = 3};
ok = mongoc_stream_writev(stream, &iov, 1, 0 /* timeout */); // Want to be non-blocking.
ASSERT_CMPSSIZE_T(ok, ==, 3);
mongoc_stream_destroy(stream);Suggest reverting to preserve the meaning of 0 as non-blocking in the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is quite unfortunate. While I could use the POSIX convention just for the public Take
If we continue to mix conventions like this, then we are just asking for errors. In my opinion, it would be best to use the POSIX convention as much as possible internally and use the spec convention only where needed for spec compliance. In the case of That said, I recognize that being unaligned with the spec in this regard is less than ideal. This also goes against the recommendation in CDRIVER-5815:
Thoughts?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Concerning "spec" vs. "POSIX" conventions, I am slightly in favor of limiting the POSIX convention to the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the important context. Upon reflection, I think I can avoid some of the mess I was previously concerned about by adding new private |
||||||
| return -1; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggest drive-by documenting the meaning of |
||||||
| } else { | ||||||
| return (bson_get_monotonic_time() + ((int64_t)timeout_msec * 1000L)); | ||||||
| } | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.