]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.7] bpo-37279: Fix asyncio sendfile support when extra data are sent in fallback...
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Sat, 15 Jun 2019 11:56:27 +0000 (14:56 +0300)
committerGitHub <noreply@github.com>
Sat, 15 Jun 2019 11:56:27 +0000 (14:56 +0300)
(cherry picked from commit ef2152354f03a165c5e3adb53e2276934fabd50a)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Lib/asyncio/base_events.py
Lib/test/test_asyncio/test_events.py
Misc/NEWS.d/next/Library/2019-06-14-13-25-56.bpo-37279.OHlW6l.rst [new file with mode: 0644]

index a9660ca1089ca4f806208637f19d08b551378ccb..52134372fa9f330b50f73faa8b8d0af8a33bf6ea 100644 (file)
@@ -827,7 +827,7 @@ class BaseEventLoop(events.AbstractEventLoop):
                 read = await self.run_in_executor(None, file.readinto, view)
                 if not read:
                     break  # EOF
-                await self.sock_sendall(sock, view)
+                await self.sock_sendall(sock, view[:read])
                 total_sent += read
             return total_sent
         finally:
@@ -1082,7 +1082,7 @@ class BaseEventLoop(events.AbstractEventLoop):
                 if not read:
                     return total_sent  # EOF
                 await proto.drain()
-                transp.write(view)
+                transp.write(view[:read])
                 total_sent += read
         finally:
             if total_sent > 0 and hasattr(file, 'seek'):
index 9466111b8ef780d4b9e791d7d6d45c816b9b3e01..d2c1d7c8a67110fb38a30d85c71de10c50f5c1c3 100644 (file)
@@ -2117,7 +2117,8 @@ class SubprocessTestsMixin:
 
 class SendfileBase:
 
-    DATA = b"SendfileBaseData" * (1024 * 8)  # 128 KiB
+    # 128 KiB plus small unaligned to buffer chunk
+    DATA = b"SendfileBaseData" * (1024 * 8 + 1)
 
     # Reduce socket buffer size to test on relative small data sets.
     BUF_SIZE = 4 * 1024   # 4 KiB
diff --git a/Misc/NEWS.d/next/Library/2019-06-14-13-25-56.bpo-37279.OHlW6l.rst b/Misc/NEWS.d/next/Library/2019-06-14-13-25-56.bpo-37279.OHlW6l.rst
new file mode 100644 (file)
index 0000000..d740b9b
--- /dev/null
@@ -0,0 +1,2 @@
+Fix asyncio sendfile support when sendfile sends extra data in fallback
+mode.