Skip to content

Commit

Permalink
Latest changes
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Dmitri Tikhonov committed Jul 10, 2018
1 parent cd7bc38 commit ccd7416
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 73 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2018-07-10

- 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.

2018-06-13

- [BUGFIX] allow multiple parallel connections by default
Expand Down
18 changes: 13 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ ENDIF()

ENDIF()

# If using older glibc, need to link with -lrt. See clock_getres(2).
EXECUTE_PROCESS(
COMMAND ${PROJECT_SOURCE_DIR}/print-glibc-version.sh ${CMAKE_C_COMPILER}
OUTPUT_VARIABLE GLIBC_VERSION)
IF(NOT GLIBC_VERSION EQUAL "" AND GLIBC_VERSION VERSION_LESS 2.17)
SET(LIBS ${LIBS} rt)
ENDIF()

# By default, we compile in development mode. To compile production code,
# pass -DDEVEL_MODE=0 to cmake (before that, `make clean' and remove any
# cmake cache files).
Expand Down Expand Up @@ -45,7 +53,7 @@ IF(DEVEL_MODE EQUAL 1)
ENDIF()
# Uncomment to enable fault injection testing via libfiu:
#SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1")
#SET (FIULIB "fiu")
#SET(LIBS ${LIBS} fiu)
ELSE()
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O3 -g0")
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DNDEBUG")
Expand Down Expand Up @@ -73,7 +81,7 @@ SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -W4 -WX -Zi -DWIN32_LEAN_AND_MEAN -DNOMINM
IF(DEVEL_MODE EQUAL 1)
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Od")
#SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1")
#SET (FIULIB "fiu")
#SET(LIBS ${LIBS} fiu)
ELSE()
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Ox")
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DNDEBUG")
Expand Down Expand Up @@ -120,7 +128,7 @@ add_executable(http_client
test/prog.c
test/test_common.c
)
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${FIULIB} z m)
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${LIBS} z m)

#MSVC
ELSE()
Expand All @@ -144,11 +152,11 @@ target_link_libraries(http_client
optimized ${VCPKG_BASE_DIR}/lib/zlib.lib
optimized ${BORINGSSL_BASE_LIB_DIR}/ssl/release/ssl.lib
optimized ${BORINGSSL_BASE_LIB_DIR}/crypto/release/crypto.lib
${FIULIB} )
${LIBS} )

ENDIF()

#target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${FIULIB} z m)
#target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${LIBS} z m)

add_subdirectory(src)

Expand Down
7 changes: 4 additions & 3 deletions include/lsquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@
#include <lsquic_types.h>
#ifndef WIN32
#include <sys/uio.h>
#include <sys/types.h>
#include <time.h>
#include <sys/queue.h>
#else
#include <vc_compat.h>
#endif

struct iovec;
struct sockaddr;

#ifdef __cplusplus
extern "C" {
#endif

#define LSQUIC_MAJOR_VERSION 1
#define LSQUIC_MINOR_VERSION 10
#define LSQUIC_PATCH_VERSION 1

/**
* Engine flags:
*/
Expand Down
13 changes: 13 additions & 0 deletions print-glibc-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
#
# Determine glibc version and print it to stdout. I have to resort to
# using a shell script because it is taking too long to figure out how
# to do this properly in cmake.

CC=$1
if [ "" = "$CC" ]; then
CC=gcc
fi

$CC -print-file-name=libc.so.6 \
| perl -plne '$_ = readlink if -H; s/\.so$// && s/.*-//'
8 changes: 1 addition & 7 deletions test/prog.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,13 @@ void
prog_init (struct prog *, unsigned lsquic_engine_flags, struct sport_head *,
const struct lsquic_stream_if *, void *stream_if_ctx);

#if HAVE_SENDMMSG
# define SENDMMSG_FLAG "g"
#else
# define SENDMMSG_FLAG ""
#endif

#if LSQUIC_DONTFRAG_SUPPORTED
# define IP_DONTFRAG_FLAG "D"
#else
# define IP_DONTFRAG_FLAG ""
#endif

#define PROG_OPTS "m:c:y:L:l:o:H:s:S:Y:z:" SENDMMSG_FLAG IP_DONTFRAG_FLAG
#define PROG_OPTS "m:c:y:L:l:o:H:s:S:Y:z:" IP_DONTFRAG_FLAG

/* Returns:
* 0 Applied
Expand Down
15 changes: 9 additions & 6 deletions test/test_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "../src/liblsquic/lsquic_logger.h"

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

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

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

for (n = 0; n < iter.ri_idx; ++n)
if (0 != lsquic_engine_packet_in(engine,
if (0 > lsquic_engine_packet_in(engine,
#ifndef WIN32
packs_in->vecs[n].iov_base,
packs_in->vecs[n].iov_len,
Expand All @@ -581,14 +584,14 @@ read_handler (evutil_socket_t fd, short flags, void *ctx)
(struct sockaddr *) &packs_in->peer_addresses[n],
sport))
break;

if (n > 0)
prog_process_conns(sport->sp_prog);
}
while (ROP_NOROOM == rop);
while (ROP_NOROOM == rop && !prog_is_stopped());

if (n_batches)
n += packs_in->n_alloc * (n_batches - 1);

if (!prog_is_stopped())
prog_process_conns(sport->sp_prog);
n += n_alloc * (n_batches - 1);

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

0 comments on commit ccd7416

Please sign in to comment.