Skip to content

Commit ccd7416

Browse files
author
Dmitri Tikhonov
committed
Latest changes
- 1.10.1 - [BUGFIX] process connections after each batch of packets is read This avoids a problem of accumulating a very large list of packets (possible when speeds are high and socket's receive buffer is large) and processing it all at once. - If glibc is older than 2.17, link with rt. This is necessary for clock_getres(2). - Add version macros to lsquic.h; remove unnecessary includes.
1 parent cd7bc38 commit ccd7416

File tree

7 files changed

+103
-73
lines changed

7 files changed

+103
-73
lines changed

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2018-07-10
2+
3+
- 1.10.1
4+
- [BUGFIX] process connections after each batch of packets is read
5+
This avoids a problem of accumulating a very large list of packets
6+
(possible when speeds are high and socket's receive buffer is large)
7+
and processing it all at once.
8+
- If glibc is older than 2.17, link with rt. This is necessary for
9+
clock_getres(2).
10+
- Add version macros to lsquic.h; remove unnecessary includes.
11+
112
2018-06-13
213

314
- [BUGFIX] allow multiple parallel connections by default

CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ ENDIF()
1717

1818
ENDIF()
1919

20+
# If using older glibc, need to link with -lrt. See clock_getres(2).
21+
EXECUTE_PROCESS(
22+
COMMAND ${PROJECT_SOURCE_DIR}/print-glibc-version.sh ${CMAKE_C_COMPILER}
23+
OUTPUT_VARIABLE GLIBC_VERSION)
24+
IF(NOT GLIBC_VERSION EQUAL "" AND GLIBC_VERSION VERSION_LESS 2.17)
25+
SET(LIBS ${LIBS} rt)
26+
ENDIF()
27+
2028
# By default, we compile in development mode. To compile production code,
2129
# pass -DDEVEL_MODE=0 to cmake (before that, `make clean' and remove any
2230
# cmake cache files).
@@ -45,7 +53,7 @@ IF(DEVEL_MODE EQUAL 1)
4553
ENDIF()
4654
# Uncomment to enable fault injection testing via libfiu:
4755
#SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1")
48-
#SET (FIULIB "fiu")
56+
#SET(LIBS ${LIBS} fiu)
4957
ELSE()
5058
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O3 -g0")
5159
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DNDEBUG")
@@ -73,7 +81,7 @@ SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -W4 -WX -Zi -DWIN32_LEAN_AND_MEAN -DNOMINM
7381
IF(DEVEL_MODE EQUAL 1)
7482
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Od")
7583
#SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1")
76-
#SET (FIULIB "fiu")
84+
#SET(LIBS ${LIBS} fiu)
7785
ELSE()
7886
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Ox")
7987
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DNDEBUG")
@@ -120,7 +128,7 @@ add_executable(http_client
120128
test/prog.c
121129
test/test_common.c
122130
)
123-
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${FIULIB} z m)
131+
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${LIBS} z m)
124132

125133
#MSVC
126134
ELSE()
@@ -144,11 +152,11 @@ target_link_libraries(http_client
144152
optimized ${VCPKG_BASE_DIR}/lib/zlib.lib
145153
optimized ${BORINGSSL_BASE_LIB_DIR}/ssl/release/ssl.lib
146154
optimized ${BORINGSSL_BASE_LIB_DIR}/crypto/release/crypto.lib
147-
${FIULIB} )
155+
${LIBS} )
148156

149157
ENDIF()
150158

151-
#target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${FIULIB} z m)
159+
#target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${LIBS} z m)
152160

153161
add_subdirectory(src)
154162

include/lsquic.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@
1212
#include <lsquic_types.h>
1313
#ifndef WIN32
1414
#include <sys/uio.h>
15-
#include <sys/types.h>
1615
#include <time.h>
17-
#include <sys/queue.h>
1816
#else
1917
#include <vc_compat.h>
2018
#endif
2119

22-
struct iovec;
2320
struct sockaddr;
2421

2522
#ifdef __cplusplus
2623
extern "C" {
2724
#endif
2825

26+
#define LSQUIC_MAJOR_VERSION 1
27+
#define LSQUIC_MINOR_VERSION 10
28+
#define LSQUIC_PATCH_VERSION 1
29+
2930
/**
3031
* Engine flags:
3132
*/

print-glibc-version.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
#
3+
# Determine glibc version and print it to stdout. I have to resort to
4+
# using a shell script because it is taking too long to figure out how
5+
# to do this properly in cmake.
6+
7+
CC=$1
8+
if [ "" = "$CC" ]; then
9+
CC=gcc
10+
fi
11+
12+
$CC -print-file-name=libc.so.6 \
13+
| perl -plne '$_ = readlink if -H; s/\.so$// && s/.*-//'

test/prog.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,13 @@ void
3535
prog_init (struct prog *, unsigned lsquic_engine_flags, struct sport_head *,
3636
const struct lsquic_stream_if *, void *stream_if_ctx);
3737

38-
#if HAVE_SENDMMSG
39-
# define SENDMMSG_FLAG "g"
40-
#else
41-
# define SENDMMSG_FLAG ""
42-
#endif
43-
4438
#if LSQUIC_DONTFRAG_SUPPORTED
4539
# define IP_DONTFRAG_FLAG "D"
4640
#else
4741
# define IP_DONTFRAG_FLAG ""
4842
#endif
4943

50-
#define PROG_OPTS "m:c:y:L:l:o:H:s:S:Y:z:" SENDMMSG_FLAG IP_DONTFRAG_FLAG
44+
#define PROG_OPTS "m:c:y:L:l:o:H:s:S:Y:z:" IP_DONTFRAG_FLAG
5145

5246
/* Returns:
5347
* 0 Applied

test/test_common.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "../src/liblsquic/lsquic_logger.h"
4444

4545
#define MAX(a, b) ((a) > (b) ? (a) : (b))
46+
#define MIN(a, b) ((a) < (b) ? (a) : (b))
4647

4748
#ifndef WIN32
4849
# define SOCKET_TYPE int
@@ -552,6 +553,8 @@ read_handler (evutil_socket_t fd, short flags, void *ctx)
552553
struct packets_in *packs_in = sport->packs_in;
553554
struct read_iter iter;
554555
unsigned n, n_batches;
556+
/* Save the value in case program is stopped packs_in is freed: */
557+
const unsigned n_alloc = packs_in->n_alloc;
555558
enum rop rop;
556559

557560
n_batches = 0;
@@ -569,7 +572,7 @@ read_handler (evutil_socket_t fd, short flags, void *ctx)
569572
n_batches += iter.ri_idx > 0;
570573

571574
for (n = 0; n < iter.ri_idx; ++n)
572-
if (0 != lsquic_engine_packet_in(engine,
575+
if (0 > lsquic_engine_packet_in(engine,
573576
#ifndef WIN32
574577
packs_in->vecs[n].iov_base,
575578
packs_in->vecs[n].iov_len,
@@ -581,14 +584,14 @@ read_handler (evutil_socket_t fd, short flags, void *ctx)
581584
(struct sockaddr *) &packs_in->peer_addresses[n],
582585
sport))
583586
break;
587+
588+
if (n > 0)
589+
prog_process_conns(sport->sp_prog);
584590
}
585-
while (ROP_NOROOM == rop);
591+
while (ROP_NOROOM == rop && !prog_is_stopped());
586592

587593
if (n_batches)
588-
n += packs_in->n_alloc * (n_batches - 1);
589-
590-
if (!prog_is_stopped())
591-
prog_process_conns(sport->sp_prog);
594+
n += n_alloc * (n_batches - 1);
592595

593596
LSQ_DEBUG("read %u packet%.*s in %u batch%s", n, n != 1, "s", n_batches, n_batches != 1 ? "es" : "");
594597
}

0 commit comments

Comments
 (0)