diff options
| author | Simon Rettberg | 2025-10-16 14:50:30 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2025-12-09 15:33:20 +0100 |
| commit | 619502eea60436f50b63300ab3d4e73077f5194c (patch) | |
| tree | 47e52ee43d51a2760bd07422d0cdb334a1107930 /src/shared/sockhelper.c | |
| parent | [SERVER] iscsi refactor: First working version (diff) | |
| download | dnbd3-619502eea60436f50b63300ab3d4e73077f5194c.tar.gz dnbd3-619502eea60436f50b63300ab3d4e73077f5194c.tar.xz dnbd3-619502eea60436f50b63300ab3d4e73077f5194c.zip | |
[SERVER] iscsi: use sendfile()
Diffstat (limited to 'src/shared/sockhelper.c')
| -rw-r--r-- | src/shared/sockhelper.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/sockhelper.c b/src/shared/sockhelper.c index 5096320..6972957 100644 --- a/src/shared/sockhelper.c +++ b/src/shared/sockhelper.c @@ -438,3 +438,15 @@ ssize_t sock_recv(const int sock, void *buffer, const size_t len) return done; } +bool sock_sendPadding(const int fd, uint32_t bytes) +{ + static char nullbytes[512] = {0}; + + while ( bytes >= sizeof(nullbytes) ) { + ssize_t ret = sock_sendAll( fd, nullbytes, sizeof(nullbytes), 2 ); + if ( ret <= 0 ) + return false; + bytes -= (uint32_t)ret; + } + return sock_sendAll( fd, nullbytes, bytes, 2 ) == (ssize_t)bytes; +}
\ No newline at end of file |
