Commit 975448f8 authored by Oscar Olsson's avatar Oscar Olsson
Browse files

protocol_received decodes until error

parent 6fedc239
......@@ -205,7 +205,9 @@ void protocol_data_received(struct firefly_connection *conn,
labcomm_decoder_ioctl(conn->transport_decoder,
FIREFLY_LABCOMM_IOCTL_READER_SET_BUFFER,
data, size);
labcomm_decoder_decode_one(conn->transport_decoder);
int res = 0;
while (res >= 0)
res = labcomm_decoder_decode_one(conn->transport_decoder);
}
}
......
......@@ -79,10 +79,12 @@ void ping_chan_restr_info(struct firefly_channel *chan,
switch (restr) {
case UNRESTRICTED:
/* Done */
printf("PING: chan unrestricted\n");
ping_pass_test(CHAN_UNRESTRICTED);
firefly_channel_close(chan);
break;
case RESTRICTED:
printf("PING: chan restricted\n");
ping_pass_test(CHAN_RESTRICTED);
/* Send data */
send_data(chan);
......@@ -147,11 +149,10 @@ void *send_data(void *args)
void ping_handle_pingpong_data(pingpong_data *data, void *ctx)
{
UNUSED_VAR(ctx);
printf("PING: recieved data\n");
if (*data == PONG_DATA)
ping_pass_test(DATA_RECEIVE);
firefly_channel_unrestrict(ctx);
}
struct firefly_connection_actions ping_actions = {
......
......@@ -91,6 +91,7 @@ void pong_chan_restr_info(struct firefly_channel *chan,
bool pong_chan_restr(struct firefly_channel *chan)
{
UNUSED_VAR(chan);
printf("PONG: chan restriction accepted\n");
pong_pass_test(CHAN_RESTRICTED);
......@@ -109,7 +110,7 @@ struct firefly_connection_actions pong_actions = {
void pong_connection_opened(struct firefly_connection *conn)
{
printf("conn opened\n");
printf("PONG: conn opened\n");
UNUSED_VAR(conn);
pong_pass_test(CONNECTION_OPEN);
}
......@@ -150,7 +151,7 @@ void pong_chan_opened(struct firefly_channel *chan)
void pong_chan_closed(struct firefly_channel *chan)
{
printf("chan closed\n");
printf("PONG: chan closed\n");
pong_pass_test(CHAN_CLOSE);
firefly_connection_close(firefly_channel_get_connection(chan));
pthread_mutex_lock(&pong_done_lock);
......@@ -162,7 +163,7 @@ void pong_chan_closed(struct firefly_channel *chan)
bool pong_chan_received(struct firefly_channel *chan)
{
UNUSED_VAR(chan);
printf("chan recv\n");
printf("PONG: chan recv\n");
pong_pass_test(CHAN_RECEIVE);
return true;
......@@ -170,13 +171,14 @@ bool pong_chan_received(struct firefly_channel *chan)
void pong_channel_rejected(struct firefly_connection *conn)
{
printf("chan rej\n");
printf("PONG: chan rej\n");
UNUSED_VAR(conn);
fprintf(stderr, "ERROR: Channel rejected.\n");
}
void pong_handle_pingpong_data(pingpong_data *data, void *ctx)
{
printf("PONG: recieved data\n");
UNUSED_VAR(data);
pong_pass_test(DATA_RECEIVE);
send_data_and_close(ctx);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment