must use stream with tcp + fix pointer arithmetic

This commit is contained in:
Quentin 2021-01-14 18:13:12 +01:00
parent d4c0af56a4
commit cd4510a1a0
2 changed files with 10 additions and 3 deletions

View file

@ -133,14 +133,19 @@ int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
} else {
// Does not exist yet, we use a tmp stub.
ms = &ms_transi;
ms->fd = fdinfo->fd;
ms->mp_nin = 0;
}
// 2. Read data in our measurement object
ms->mp_nin = mctx->connectionless && mctx->role == MEASLAT_SERVER ?
nread = mctx->connectionless && mctx->role == MEASLAT_SERVER ?
recvfrom(fdinfo->fd, ms->mp_in, mctx->mp.payload_size, MSG_TRUNC, (struct sockaddr*)&mctx->addr, &mctx->addrlen) :
recv(fdinfo->fd, ms->mp_in, mctx->mp.payload_size, 0);
recv(fdinfo->fd, ((char*) ms->mp_in) + ms->mp_nin, mctx->mp.payload_size - ms->mp_nin, 0);
if (ms->mp_nin <= 0) return 1;
if (nread <= 0) return 1;
ms->mp_nin += nread;
if (ms->mp_nin < mctx->mp.payload_size) return 0;
// 3. Process data in our measurement object
measure_parse (&mctx->mp, ms);

View file

@ -79,6 +79,8 @@ void measure_parse(struct measure_params* mp, struct measure_state* ms) {
is_slow,
link_id,
is_vanilla);
ms->mp_nin = 0;
}
struct measure_packet* measure_generate(struct measure_params* mp, struct measure_state* ms) {