| 1 |
/************************************************* |
| 2 |
* Exim - an Internet mail transport agent * |
| 3 |
*************************************************/ |
| 4 |
|
| 5 |
/* Copyright (c) The Exim Maintainers 2021 - 2025 */ |
| 6 |
/* Copyright (c) Jeremy Harris 1995 - 2020 */ |
| 7 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 8 |
/* See the file NOTICE for conditions of use and distribution. */ |
| 9 |
|
| 10 |
/* FreeBSD-specific code. This is concatenated onto the generic |
| 11 |
src/os.c file. */ |
| 12 |
|
| 13 |
|
| 14 |
/************* |
| 15 |
Sendfile shim |
| 16 |
*************/ |
| 17 |
|
| 18 |
ssize_t |
| 19 |
os_sendfile(int out, int in, off_t * offp, size_t cnt) |
| 20 |
{ |
| 21 |
off_t loff = offp ? *offp : 0; |
| 22 |
off_t written; |
| 23 |
|
| 24 |
if (sendfile(in, out, loff, cnt, NULL, &written, 0) < 0) return (ssize_t)-1; |
| 25 |
if (offp) *offp = loff + written; |
| 26 |
return (ssize_t)written; |
| 27 |
} |
| 28 |
|
| 29 |
/************************************************* |
| 30 |
TCP Fast Open: check that the ioctl is accepted |
| 31 |
*************************************************/ |
| 32 |
|
| 33 |
#ifndef COMPILE_UTILITY |
| 34 |
void |
| 35 |
tfo_probe(void) |
| 36 |
{ |
| 37 |
# ifdef TCP_FASTOPEN |
| 38 |
int sock; |
| 39 |
|
| 40 |
if ( (sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0 |
| 41 |
&& setsockopt(sock, IPPROTO_TCP, TCP_FASTOPEN, &on, sizeof(on)) >= 0 |
| 42 |
) |
| 43 |
f.tcp_fastopen_ok = TRUE; |
| 44 |
close(sock); |
| 45 |
# endif |
| 46 |
} |
| 47 |
#endif |
| 48 |
|
| 49 |
|
| 50 |
/* End of os.c-Linux */ |