Release 2.19.10 -- Fix Windows and MacOS builds

This commit is contained in:
Dmitri Tikhonov 2020-09-08 14:16:25 -04:00
parent 2f2f436324
commit c3c69ba3bb
7 changed files with 53 additions and 9 deletions

View file

@ -1,5 +1,5 @@
2020-09-08 2020-09-08
- 2.19.9 - 2.19.10
- [FEATURE] Add lsquic_stream_pwritev(). This function allows one to - [FEATURE] Add lsquic_stream_pwritev(). This function allows one to
reduce the number of system calls required to read a file from disk reduce the number of system calls required to read a file from disk
by using lsquic_stream_pwritev() together with preadv(2). by using lsquic_stream_pwritev() together with preadv(2).

View file

@ -19,6 +19,12 @@ CHECK_SYMBOL_EXISTS(
HAVE_IP_DONTFRAG HAVE_IP_DONTFRAG
) )
CHECK_SYMBOL_EXISTS(
preadv
"sys/uio.h"
HAVE_PREADV
)
INCLUDE(CheckIncludeFiles) INCLUDE(CheckIncludeFiles)
IF (MSVC AND PCRE_LIB) IF (MSVC AND PCRE_LIB)

View file

@ -578,8 +578,12 @@ bytes_left (lsquic_stream_ctx_t *st_h)
static ssize_t static ssize_t
my_preadv (void *user_data, const struct iovec *iov, int iovcnt) my_preadv (void *user_data, const struct iovec *iov, int iovcnt)
{ {
#if HAVE_PREADV
lsquic_stream_ctx_t *const st_h = user_data; lsquic_stream_ctx_t *const st_h = user_data;
return preadv(st_h->file_fd, iov, iovcnt, st_h->written); return preadv(st_h->file_fd, iov, iovcnt, st_h->written);
#else
return -1;
#endif
} }
@ -1594,10 +1598,12 @@ usage (const char *prog)
" -p FILE Push request with this path\n" " -p FILE Push request with this path\n"
" -w SIZE Write immediately (LSWS mode). Argument specifies maximum\n" " -w SIZE Write immediately (LSWS mode). Argument specifies maximum\n"
" size of the immediate write.\n" " size of the immediate write.\n"
#if HAVE_PREADV
" -P SIZE Use preadv(2) to read from disk and lsquic_stream_pwritev() to\n" " -P SIZE Use preadv(2) to read from disk and lsquic_stream_pwritev() to\n"
" write to stream. Positive SIZE indicate maximum value per\n" " write to stream. Positive SIZE indicate maximum value per\n"
" write; negative means always use remaining file size.\n" " write; negative means always use remaining file size.\n"
" Incompatible with -w.\n" " Incompatible with -w.\n"
#endif
" -y DELAY Delay response for this many seconds -- use for debugging\n" " -y DELAY Delay response for this many seconds -- use for debugging\n"
, prog); , prog);
} }
@ -1799,8 +1805,14 @@ main (int argc, char **argv)
s_immediate_write = atoi(optarg); s_immediate_write = atoi(optarg);
break; break;
case 'P': case 'P':
#if HAVE_PREADV
s_pwritev = strtoull(optarg, NULL, 10); s_pwritev = strtoull(optarg, NULL, 10);
break; break;
#else
fprintf(stderr, "preadv is not supported on this platform, "
"cannot use -P\n");
exit(EXIT_FAILURE);
#endif
case 'y': case 'y':
server_ctx.delay_resp_sec = atoi(optarg); server_ctx.delay_resp_sec = atoi(optarg);
break; break;

View file

@ -7,6 +7,7 @@
#cmakedefine HAVE_IP_DONTFRAG 1 #cmakedefine HAVE_IP_DONTFRAG 1
#cmakedefine HAVE_IP_MTU_DISCOVER 1 #cmakedefine HAVE_IP_MTU_DISCOVER 1
#cmakedefine HAVE_REGEX 1 #cmakedefine HAVE_REGEX 1
#cmakedefine HAVE_PREADV 1
#define LSQUIC_DONTFRAG_SUPPORTED (HAVE_IP_DONTFRAG || HAVE_IP_MTU_DISCOVER) #define LSQUIC_DONTFRAG_SUPPORTED (HAVE_IP_DONTFRAG || HAVE_IP_MTU_DISCOVER)

View file

@ -26,7 +26,7 @@ author = u'LiteSpeed Technologies'
# The short X.Y version # The short X.Y version
version = u'2.19' version = u'2.19'
# The full version, including alpha/beta/rc tags # The full version, including alpha/beta/rc tags
release = u'2.19.9' release = u'2.19.10'
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------

View file

@ -25,7 +25,7 @@ extern "C" {
#define LSQUIC_MAJOR_VERSION 2 #define LSQUIC_MAJOR_VERSION 2
#define LSQUIC_MINOR_VERSION 19 #define LSQUIC_MINOR_VERSION 19
#define LSQUIC_PATCH_VERSION 9 #define LSQUIC_PATCH_VERSION 10
/** /**
* Engine flags: * Engine flags:

View file

@ -3604,6 +3604,11 @@ lsquic_stream_writef (lsquic_stream_t *stream, struct lsquic_reader *reader)
#define PWRITEV_IOVECS LSQUIC_PWRITEV_DEF_IOVECS #define PWRITEV_IOVECS LSQUIC_PWRITEV_DEF_IOVECS
#define PWRITEV_FRAMES LSQUIC_PWRITEV_DEF_FRAMES #define PWRITEV_FRAMES LSQUIC_PWRITEV_DEF_FRAMES
#else #else
#if _MSC_VER
#define MALLOC_PWRITEV 1
#else
#define MALLOC_PWRITEV 0
#endif
static unsigned static unsigned
PWRITEV_IOVECS = LSQUIC_PWRITEV_DEF_IOVECS, PWRITEV_IOVECS = LSQUIC_PWRITEV_DEF_IOVECS,
PWRITEV_FRAMES = LSQUIC_PWRITEV_DEF_FRAMES; PWRITEV_FRAMES = LSQUIC_PWRITEV_DEF_FRAMES;
@ -3670,8 +3675,14 @@ lsquic_stream_pwritev (struct lsquic_stream *stream,
void *user_data, size_t n_to_write) void *user_data, size_t n_to_write)
{ {
struct lsquic_send_ctl *const ctl = stream->conn_pub->send_ctl; struct lsquic_send_ctl *const ctl = stream->conn_pub->send_ctl;
struct iovec iovecs[PWRITEV_IOVECS], *last_iov; #if MALLOC_PWRITEV
struct iovec *iovecs;
unsigned char **hq_frames;
#else
struct iovec iovecs[PWRITEV_IOVECS];
unsigned char *hq_frames[PWRITEV_FRAMES]; unsigned char *hq_frames[PWRITEV_FRAMES];
#endif
struct iovec *last_iov;
struct pwritev_ctx ctx; struct pwritev_ctx ctx;
struct lsquic_reader reader; struct lsquic_reader reader;
struct send_ctl_state ctl_state; struct send_ctl_state ctl_state;
@ -3685,18 +3696,29 @@ lsquic_stream_pwritev (struct lsquic_stream *stream,
COMMON_WRITE_CHECKS(); COMMON_WRITE_CHECKS();
SM_HISTORY_APPEND(stream, SHE_USER_WRITE_DATA); SM_HISTORY_APPEND(stream, SHE_USER_WRITE_DATA);
#if MALLOC_PWRITEV
iovecs = malloc(sizeof(iovecs[0]) * PWRITEV_IOVECS);
hq_frames = malloc(sizeof(hq_frames[0]) * PWRITEV_FRAMES);
if (!(iovecs && hq_frames))
{
free(iovecs);
free(hq_frames);
return -1;
}
#endif
lsquic_send_ctl_snapshot(ctl, &ctl_state); lsquic_send_ctl_snapshot(ctl, &ctl_state);
ctx.total_bytes = 0; ctx.total_bytes = 0;
ctx.n_to_write = n_to_write; ctx.n_to_write = n_to_write;
ctx.n_iovecs = 0; ctx.n_iovecs = 0;
ctx.max_iovecs = sizeof(iovecs) / sizeof(iovecs[0]); ctx.max_iovecs = PWRITEV_IOVECS;
ctx.iov = iovecs; ctx.iov = iovecs;
ctx.hq_arr = &hq_arr; ctx.hq_arr = &hq_arr;
hq_arr.p = hq_frames; hq_arr.p = hq_frames;
hq_arr.count = 0; hq_arr.count = 0;
hq_arr.max = sizeof(hq_frames) / sizeof(hq_frames[0]); hq_arr.max = PWRITEV_FRAMES;
stream->sm_hq_arr = &hq_arr; stream->sm_hq_arr = &hq_arr;
reader.lsqr_ctx = &ctx; reader.lsqr_ctx = &ctx;
@ -3719,6 +3741,10 @@ lsquic_stream_pwritev (struct lsquic_stream *stream,
cleanup: cleanup:
stream->sm_hq_arr = NULL; stream->sm_hq_arr = NULL;
#if MALLOC_PWRITEV
free(iovecs);
free(hq_frames);
#endif
return nw; return nw;
unwind_short_write: unwind_short_write:
@ -3790,15 +3816,14 @@ lsquic_stream_pwritev (struct lsquic_stream *stream,
/* Find last iovec: */ /* Find last iovec: */
sum = 0; sum = 0;
for (last_iov = iovecs; last_iov for (last_iov = iovecs; last_iov < iovecs + PWRITEV_IOVECS; ++last_iov)
< iovecs + sizeof(iovecs)/sizeof(iovecs[0]); ++last_iov)
{ {
sum += last_iov->iov_len; sum += last_iov->iov_len;
if ((last_iov == iovecs || (size_t) nw > sum - last_iov->iov_len) if ((last_iov == iovecs || (size_t) nw > sum - last_iov->iov_len)
&& (size_t) nw <= sum) && (size_t) nw <= sum)
break; break;
} }
assert(last_iov < iovecs + sizeof(iovecs)/sizeof(iovecs[0])); assert(last_iov < iovecs + PWRITEV_IOVECS);
lsquic_send_ctl_rollback(ctl, &ctl_state, last_iov, sum - nw); lsquic_send_ctl_rollback(ctl, &ctl_state, last_iov, sum - nw);
goto cleanup; goto cleanup;