This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.sendfile() support missing for AIX platform
Type: enhancement Stage:
Components: IO Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Michael.Felt
Priority: normal Keywords:

Created on 2019-06-19 08:36 by Michael.Felt, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg346029 - (view) Author: Michael Felt (Michael.Felt) * Date: 2019-06-19 08:36
In AIX "sendfile()" is named send_file().

During testing I learned, unexpectedly, that AIX platform has never provided support of os.sendfile(). This is correct that oversight.

From this (and older) documentation - it seems all the bits needed are available. See https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.commtrf2/send_file.htm

At this point - I am assuming that os.sendfile() is for the "socket sendfile() - but would like feedback in case "there is more". As to compareable concerns in the past see: https://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00506.html
msg361339 - (view) Author: Michael Felt (Michael.Felt) * Date: 2020-02-04 08:33
OK. Couple of months later.

Would appreciate guidance before submitting a patch.

In advance: Thank you for your time and consideration.

Short: socket.sendfile() and AIX send_file() are very close in terms of functionality - especially the requirement that "out_fd" is a non-blocking socket.
os.sendfile() and AIX send_file(), imho, do not match because it appears that os.sendfile(in_fd, out_fd, ...) will work with any kind of open file descriptor.

Longer:
.. method:: socket.sendfile(file, offset=0, count=None)

   Send a file until EOF is reached by using high-performance
   :mod:`os.sendfile` and return the total number of bytes which were sent.
   *file* must be a regular file object opened in binary mode. If
   :mod:`os.sendfile` is not available (e.g. Windows) or *file* is not a
   regular file :meth:`send` will be used instead. 
...
 The socket must be of :const:`SOCK_STREAM` type.
   Non-blocking sockets are not supported.

   .. versionadded:: 3.5

AIX

#include < sys/socket.h >

ssize_t send_file(Socket_p, sf_iobuf, flags)

int * Socket_p;
struct sf_parms * sf_iobuf;
uint_t  flags;
Description

The send_file subroutine sends data from the opened file specified in the sf_iobuf parameter, over the connected socket pointed to by the Socket_p parameter.

Note Currently, the send_file only supports the TCP/IP protocol (SOCK_STREAM socket in AF_INET). An error will be returned when this function is used on any other types of sockets.

**** These match in terms of goals. ****

Considering the requirements of AIX send_file() os.sendfile() does not seem to fit. I read (Doc/library/os.rst) os.sendfile to imply that any
open file descriptors will be "sent" whereas with socket.sendfile - in_fd is binary file, out_fd is a SOCK_STREAM socket descriptor.

So, would like some feedback on how to proceed:

e.g., 
A. a new os.send_file - only available for AIX (and only accessible to socket.sendfile(),
B. os.sendfile  "returns" one of the following when the input parameters are not appropriate:
EBADF 	        Either the socket or the file descriptor parameter is not valid.
ENOTSOCK 	The socket parameter refers to a file, not a socket.

(There are other errno results, not important for the discussion atm).

Again, thank you for your time!
History
Date User Action Args
2022-04-11 14:59:16adminsetgithub: 81517
2020-02-04 08:33:52Michael.Feltsetmessages: + msg361339
2019-06-19 08:36:09Michael.Feltcreate