must use stream with tcp + fix pointer arithmetic
This commit is contained in:
parent
d4c0af56a4
commit
cd4510a1a0
2 changed files with 10 additions and 3 deletions
|
@ -133,14 +133,19 @@ int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
|
||||||
} else {
|
} else {
|
||||||
// Does not exist yet, we use a tmp stub.
|
// Does not exist yet, we use a tmp stub.
|
||||||
ms = &ms_transi;
|
ms = &ms_transi;
|
||||||
|
ms->fd = fdinfo->fd;
|
||||||
|
ms->mp_nin = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Read data in our measurement object
|
// 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) :
|
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
|
// 3. Process data in our measurement object
|
||||||
measure_parse (&mctx->mp, ms);
|
measure_parse (&mctx->mp, ms);
|
||||||
|
|
|
@ -79,6 +79,8 @@ void measure_parse(struct measure_params* mp, struct measure_state* ms) {
|
||||||
is_slow,
|
is_slow,
|
||||||
link_id,
|
link_id,
|
||||||
is_vanilla);
|
is_vanilla);
|
||||||
|
|
||||||
|
ms->mp_nin = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct measure_packet* measure_generate(struct measure_params* mp, struct measure_state* ms) {
|
struct measure_packet* measure_generate(struct measure_params* mp, struct measure_state* ms) {
|
||||||
|
|
Loading…
Reference in a new issue