nsendfile

This commit is contained in:
quackerd 2023-04-07 23:24:33 +02:00
parent c6dadbe9e3
commit a67a4ca349
3 changed files with 10 additions and 10 deletions

View File

@ -100,13 +100,13 @@ iperf_tcp_send(struct iperf_stream *sp)
if (sp->ssl) {
if (sp->test->zerocopy) {
if (sp->test->diskfile_name != NULL) {
r = Nsendfile_ssl(sp->diskfile_fd, sp->ssl, sp->diskfile_offset, sp->pending_size);
r = Nsendfile_ssl(sp->diskfile_fd, sp->ssl, sp->diskfile_offset, sp->pending_size, SF_NOCACHE);
sp->diskfile_offset += r;
if (sp->diskfile_offset + sp->settings->blksize >= sp->diskfile_sz) {
sp->diskfile_offset = r;
}
} else {
r = Nsendfile_ssl(sp->buffer_fd, sp->ssl, 0, sp->pending_size);
r = Nsendfile_ssl(sp->buffer_fd, sp->ssl, 0, sp->pending_size, 0);
}
}
else {
@ -116,13 +116,13 @@ iperf_tcp_send(struct iperf_stream *sp)
#endif
if (sp->test->zerocopy) {
if (sp->test->diskfile_name != NULL) {
r = Nsendfile(sp->diskfile_fd, sp->socket, sp->diskfile_offset, sp->pending_size);
r = Nsendfile(sp->diskfile_fd, sp->socket, sp->diskfile_offset, sp->pending_size, SF_NOCACHE);
sp->diskfile_offset += r;
if (sp->diskfile_offset + sp->settings->blksize >= sp->diskfile_sz) {
sp->diskfile_offset = r;
}
} else {
r = Nsendfile(sp->buffer_fd, sp->socket, 0, sp->pending_size);
r = Nsendfile(sp->buffer_fd, sp->socket, 0, sp->pending_size, 0);
}
} else {
r = Nwrite(sp->socket, sp->buffer, sp->pending_size, Ptcp);

View File

@ -430,7 +430,7 @@ Nwrite_ssl(SSL * ssl, const char *buf, size_t count, int prot)
int
Nsendfile_ssl(int fromfd, SSL* tossl, size_t foffset, size_t count)
Nsendfile_ssl(int fromfd, SSL* tossl, size_t foffset, size_t count, int flags)
{
#if defined(HAVE_SENDFILE)
off_t offset;
@ -440,7 +440,7 @@ Nsendfile_ssl(int fromfd, SSL* tossl, size_t foffset, size_t count)
while (nleft > 0) {
offset = count - nleft;
r = SSL_sendfile(tossl, fromfd, foffset + offset, nleft, 0);
r = SSL_sendfile(tossl, fromfd, foffset + offset, nleft, flags);
if (r < 0) {
int err = SSL_get_error(tossl, r);
switch (err) {
@ -546,7 +546,7 @@ has_sendfile(void)
*/
int
Nsendfile(int fromfd, int tofd, size_t foffset, size_t count)
Nsendfile(int fromfd, int tofd, size_t foffset, size_t count, int flags)
{
off_t offset;
#if defined(HAVE_SENDFILE)
@ -564,7 +564,7 @@ Nsendfile(int fromfd, int tofd, size_t foffset, size_t count)
if (r > 0)
nleft -= r;
#elif defined(__FreeBSD__)
r = sendfile(fromfd, tofd, foffset + offset, nleft, NULL, &sent, 0);
r = sendfile(fromfd, tofd, foffset + offset, nleft, NULL, &sent, flags);
nleft -= sent;
#elif defined(__APPLE__) && defined(__MACH__) && defined(MAC_OS_X_VERSION_10_6) /* OS X */
sent = nleft;

View File

@ -34,14 +34,14 @@ int netannounce(int domain, int proto, const char *local, const char *bind_dev,
int Nread(int fd, char *buf, size_t count, int prot);
int Nwrite(int fd, const char *buf, size_t count, int prot) /* __attribute__((hot)) */;
int has_sendfile(void);
int Nsendfile(int fromfd, int tofd, size_t offset, size_t count) /* __attribute__((hot)) */;
int Nsendfile(int fromfd, int tofd, size_t offset, size_t count, int flags) /* __attribute__((hot)) */;
int setnonblocking(int fd, int nonblocking);
int getsockdomain(int sock);
int parse_qos(const char *tos);
int Nread_ssl(SSL* ssl, char *buf, size_t count, int prot);
int Nwrite_ssl(SSL * ssl, const char *buf, size_t count, int prot);
int Nsendfile_ssl(int fromfd, SSL* tossl, size_t offset, size_t count);
int Nsendfile_ssl(int fromfd, SSL* tossl, size_t offset, size_t count, int flags);
#define NET_SOFTERROR -1
#define NET_HARDERROR -2