[gnutls-devel] GnuTLS | non-KTLS sendfile (7c034622)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Wed Feb 23 14:28:00 CET 2022




Daiki Ueno started a new discussion on lib/record.c: https://gitlab.com/gnutls/gnutls/-/commit/7c03462269ddd7c6a8753c6f8796438e40193f2d#note_852536732

> +		data_to_send = ret;
> +		while (data_to_send > 0) {
> +			ret = gnutls_record_send(session, buf, data_to_send);
> +			if (ret < 0) {
> +				if (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN)
> +					continue;
> +				else
> +					goto end;
> +			}
> +			data_to_send -= ret;
> +		}
> +		send += ret;
> +	}
> +	if (offset != NULL){
> +		*offset += send;
> +		lseek(fd, -(*offset), SEEK_CUR);

Perhaps you could save the offset at the first `lseek` and restore it with SEEK_SET?

```c
off_t save_offset;
if (offset) {
  save_offset = lseek(fd, *offset, SEEK_CUR);
  // error handling
}

// read from fd

if (offset) {
  *offset += send;
  lseek(fd, save_offset, SEEK_SET);
}
```

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/commit/7c03462269ddd7c6a8753c6f8796438e40193f2d#note_852536732
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20220223/4aec53e9/attachment-0001.html>


More information about the Gnutls-devel mailing list