Bug 2036 - wrong return code from dce_readv in case it fails within multiple buffers loop
wrong return code from dce_readv in case it fails within multiple buffers loop
Product: dce
Classification: Unclassified
Component: other
All Linux
: P5 major
Assigned To: Hajime Tazaki
Depends on:
  Show dependency treegraph
Reported: 2014-12-22 08:57 EST by Rémi Houdaille
Modified: 2015-01-28 02:36 EST (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Rémi Houdaille 2014-12-22 08:57:32 EST
In file model/dce-fd.cc, the dce_readv function always returns -1 in case any internal call to dce_read fails.
But when multiple buffers are present, dce_read may work for some of them and then fail. If returning -1, the caller will see it as a global error and considers nothing was read, while actually some buffers where read. The caller has no way to know something was read and will try again later, believing that the new call to readv provides data from the beginning.
Actually if at least one buffer was read in the first place, and a failure code is returned, the corresponding data is lost.
When a socket reads this way, the flow of data is no more correct (holes in reception).

The code of readv should aknowledge for size of data correctly read in some buffers, so that the caller sees this data.

The proposed correction in the source is the following:

diff -u dce-fd.cc.orig dce-fd.cc
--- dce-fd.cc.orig      2014-12-22 12:12:11.008435976 +0100
+++ dce-fd.cc   2014-12-22 12:14:09.310234589 +0100
@@ -410,7 +410,14 @@
-          return -1;
+          if (0 == b)
+            {
+              return -1;
+            }
+          else
+            {
+              return ret;
+            }
   return ret;
Comment 1 Hajime Tazaki 2014-12-23 09:28:51 EST
thanks. applied your patch at changeset 0fd32ca088db.