[CDRIVER-756] Unchecked errors on failed network writes Created: 20/Jul/15  Updated: 11/Jan/16  Resolved: 31/Aug/15

Status: Closed
Project: C Driver
Component/s: libmongoc, network
Affects Version/s: 1.1.9
Fix Version/s: 1.2-beta1, 1.1.11

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

Issue Links:
Related
related to CDRIVER-843 WSASend incorrect error checking Closed
related to CDRIVER-788 Hang in large bulk upsert Closed
related to CDRIVER-826 Handle WSAEMSGSIZE Closed
is related to CDRIVER-770 Continue writing until all bytes have... Closed

 Description   

mongoc_socket_sendv does not return -1 for all error cases where it should.

Additionally, callers of mongoc_stream_writev in mongoc_cluster_t functions don't check for errors.



 Comments   
Comment by Githook User [ 11/Jan/16 ]

Author:

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

Message: CDRIVER-843 & CDRIVER-756: Incorrect error checking

Use int for WSASend() and debug both return value and sent bytes
Also check the return value for SOCKET_ERROR, not !0

Conflicts:
src/mongoc/mongoc-socket.c
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/63f3d5a83a2af17d18a58da554f4e299197a99c0

Comment by Githook User [ 11/Jan/16 ]

Author:

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

Message: CDRIVER-843 & CDRIVER-756: Incorrect error checking

Use int for WSASend() and debug both return value and sent bytes
Also check the return value for SOCKET_ERROR, not !0
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/4b32898894848b8ad2121743f0145f1e29dfd473

Comment by Githook User [ 11/Jan/16 ]

Author:

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

Message: CDRIVER-756: TRACE the errno, in case it is something, just not 'EGAIN'
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/14eb5aa6cdccb323fa2616208413cb92b6d98c3c

Comment by Githook User [ 11/Jan/16 ]

Author:

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

Message: CDRIVER-756: Improve debugging

Check return codes using <=
Return how much we have written, even if the last vector wasn't even tried
Plentyful traces
Disable IO dumping
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/c721869cf4a0998d5f71950d21e0133414e41b74

Comment by Githook User [ 11/Jan/16 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'}

Message: CDRIVER-756: Unchecked errors on failed network writes
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/9a4e2e8717c3c2fe2585dc02d01f34a17226ba36

Comment by Githook User [ 26/Oct/15 ]

Author:

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

Message: CDRIVER-843 & CDRIVER-756: Incorrect error checking

Use int for WSASend() and debug both return value and sent bytes
Also check the return value for SOCKET_ERROR, not !0

Conflicts:
src/mongoc/mongoc-socket.c
Branch: debian
https://github.com/mongodb/mongo-c-driver/commit/63f3d5a83a2af17d18a58da554f4e299197a99c0

Comment by Githook User [ 26/Oct/15 ]

Author:

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

Message: CDRIVER-843 & CDRIVER-756: Incorrect error checking

Use int for WSASend() and debug both return value and sent bytes
Also check the return value for SOCKET_ERROR, not !0
Branch: debian
https://github.com/mongodb/mongo-c-driver/commit/4b32898894848b8ad2121743f0145f1e29dfd473

Comment by Githook User [ 26/Oct/15 ]

Author:

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

Message: CDRIVER-756: TRACE the errno, in case it is something, just not 'EGAIN'
Branch: debian
https://github.com/mongodb/mongo-c-driver/commit/14eb5aa6cdccb323fa2616208413cb92b6d98c3c

Comment by Githook User [ 26/Oct/15 ]

Author:

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

Message: CDRIVER-756: Improve debugging

Check return codes using <=
Return how much we have written, even if the last vector wasn't even tried
Plentyful traces
Disable IO dumping
Branch: debian
https://github.com/mongodb/mongo-c-driver/commit/c721869cf4a0998d5f71950d21e0133414e41b74

Comment by Githook User [ 26/Oct/15 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'}

Message: CDRIVER-756: Unchecked errors on failed network writes
Branch: debian
https://github.com/mongodb/mongo-c-driver/commit/9a4e2e8717c3c2fe2585dc02d01f34a17226ba36

Comment by Githook User [ 28/Sep/15 ]

Author:

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

Message: CDRIVER-843 & CDRIVER-756: Incorrect error checking

Use int for WSASend() and debug both return value and sent bytes
Also check the return value for SOCKET_ERROR, not !0
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/4b32898894848b8ad2121743f0145f1e29dfd473

Comment by Githook User [ 28/Sep/15 ]

Author:

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

Message: CDRIVER-756: TRACE the errno, in case it is something, just not 'EGAIN'
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/14eb5aa6cdccb323fa2616208413cb92b6d98c3c

Comment by Githook User [ 28/Sep/15 ]

Author:

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

Message: CDRIVER-756: Improve debugging

Check return codes using <=
Return how much we have written, even if the last vector wasn't even tried
Plentyful traces
Disable IO dumping
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/c721869cf4a0998d5f71950d21e0133414e41b74

Comment by Githook User [ 28/Sep/15 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'}

Message: CDRIVER-756: Unchecked errors on failed network writes
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/9a4e2e8717c3c2fe2585dc02d01f34a17226ba36

Comment by Githook User [ 16/Sep/15 ]

Author:

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

Message: CDRIVER-843 & CDRIVER-756: Incorrect error checking

Use int for WSASend() and debug both return value and sent bytes
Also check the return value for SOCKET_ERROR, not !0

Conflicts:
src/mongoc/mongoc-socket.c
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/63f3d5a83a2af17d18a58da554f4e299197a99c0

Comment by Githook User [ 16/Sep/15 ]

Author:

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

Message: CDRIVER-843 & CDRIVER-756: Incorrect error checking

Use int for WSASend() and debug both return value and sent bytes
Also check the return value for SOCKET_ERROR, not !0
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/4b32898894848b8ad2121743f0145f1e29dfd473

Comment by Githook User [ 16/Sep/15 ]

Author:

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

Message: CDRIVER-756: TRACE the errno, in case it is something, just not 'EGAIN'
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/14eb5aa6cdccb323fa2616208413cb92b6d98c3c

Comment by Githook User [ 16/Sep/15 ]

Author:

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

Message: CDRIVER-756: Improve debugging

Check return codes using <=
Return how much we have written, even if the last vector wasn't even tried
Plentyful traces
Disable IO dumping
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/c721869cf4a0998d5f71950d21e0133414e41b74

Comment by Githook User [ 16/Sep/15 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'}

Message: CDRIVER-756: Unchecked errors on failed network writes
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/9a4e2e8717c3c2fe2585dc02d01f34a17226ba36

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: n_return is unsigned int... its not going to be negative
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/97b07488ee929a33311b865209dd3880d08c0903

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Sprinkle, sprinkle, little trace,

How I wonder what you do!
Up above the code so high,
Like a diamond in the sky.
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/8796788d8070a51ec12cf00aab58eaf9ca876f43

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Only record the errno on failure
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/7c985ce7dfdd054819bf11b826970b3c5e918f61

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: We've already returned on failure
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/835f5ddf613805284910fbbc141d36682669b959

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Repeat the [WSA]poll() on failure until we get the event we want or hit the timeout
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/4af81f92980983c0053f355b847db159c7f44968

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Simplify mongoc_socket_close()
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/68f65659b534c0e64cc97bfa6aad994b3d358ece

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Use correct failure value, and assign errno when WSAPoll fails
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/5da9035026c642cb280e7b4135aa18b2ef3eec4b

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Don't overwrite the errno into something we won't be checking for anyway
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/14e7de8aad70ecac6d2c6b405db14493891493b7

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: This iov really should be const

We can't change the API now, so instead copy it and work on the copy
to ensure we don't molest it
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/ee8c591ace99e1f1c72a7ed8b4622b22a45f9cce

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Lets not overwrite the error code blindly after successful write
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/f8207fc0a71bc74837bc3642afad15e778e01f50

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Check for both 0 and -1 as maybe-failure-or-maybe-retry codes
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/bb5008e16fad5da3b656dd9f95f4a5c51bb8f13d

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Properly check for error in mongoc_stream_writev

And add additional checks to verify the full write succeeded, or else
return descriptive error
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/ef9aaf212e0d2cfda40df728f0fa1322c8752bc2

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Make sure our iovec abstraction is compatible with Windows WSABUF

We cast mongoc_iovec_t to LPWSABUF in our sendmsg() wrapper
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/724948b4d891a91e2912497c1a3e544543b501b1

Comment by Githook User [ 31/Aug/15 ]

Author:

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

Message: CDRIVER-756: Basic stream test
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/aa81a0b48e69540f4e9c65a82e72ae94964c71fd

Comment by Githook User [ 20/Aug/15 ]

Author:

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

Message: Merge branch '1.2.0-dev' of github.com:mongodb/mongo-c-driver into CDRIVER-756-network-failures

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