forked from M-Labs/artiq
1
0
Fork 0

session.c: bring back session_ack_{consumed,sent}.

These (called session_ack_{data,mem} before) were removed in error.
This commit is contained in:
whitequark 2015-08-08 14:06:11 +03:00
parent 4efae2b67d
commit f5ea202e25
4 changed files with 30 additions and 10 deletions

View File

@ -191,7 +191,8 @@ static void serial_service(void)
if(txlen > 0) {
for(i = 0; i < txlen; i++)
uart_write(txdata[i]);
session_ack(txlen);
session_ack_consumed(txlen);
session_ack_sent(txlen);
} else if(txlen < 0) {
reset_serial_session(1);
}

View File

@ -89,7 +89,7 @@ static err_t net_server_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err
static err_t net_server_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
session_ack(len);
session_ack_sent(len);
return ERR_OK;
}
@ -205,6 +205,7 @@ void net_server_service(void)
if(len > sndbuf)
len = sndbuf;
tcp_write(active_pcb, data, len, 0);
session_ack_consumed(len);
}
if(len < 0)
net_server_close(active_cs, active_pcb);

View File

@ -158,12 +158,13 @@ static union {
} __attribute__((packed)) header;
} buffer_out;
static int buffer_out_read_cursor, buffer_out_write_cursor;
static int buffer_out_read_cursor, buffer_out_sent_cursor, buffer_out_write_cursor;
static void out_packet_reset()
{
buffer_out_read_cursor = 0;
buffer_out_write_cursor = 0;
buffer_out_sent_cursor = 0;
}
static int out_packet_available()
@ -182,17 +183,28 @@ static void out_packet_extract(void **data, int *length)
}
}
static void out_packet_advance(int length)
static void out_packet_advance_consumed(int length)
{
if(buffer_out_read_cursor + length > buffer_out_write_cursor) {
log("session.c: write underrun while trying to acknowledge %d bytes"
" (%d remaining)",
log("session.c: write underrun (consume) while trying to"
" acknowledge %d bytes (%d remaining)",
length, buffer_out_write_cursor - buffer_out_read_cursor);
return;
}
buffer_out_read_cursor += length;
if(buffer_out_read_cursor == buffer_out_write_cursor)
}
static void out_packet_advance_sent(int length) {
if(buffer_out_sent_cursor + length > buffer_out_write_cursor) {
log("session.c: write underrun (send) while trying to"
" acknowledge %d bytes (%d remaining)",
length, buffer_out_write_cursor - buffer_out_sent_cursor);
return;
}
buffer_out_sent_cursor += length;
if(buffer_out_sent_cursor == buffer_out_write_cursor)
out_packet_reset();
}
@ -652,7 +664,12 @@ void session_poll(void **data, int *length)
out_packet_extract(data, length);
}
void session_ack(int length)
void session_ack_consumed(int length)
{
out_packet_advance(length);
out_packet_advance_consumed(length);
}
void session_ack_sent(int length)
{
out_packet_advance_sent(length);
}

View File

@ -6,6 +6,7 @@ void session_end(void);
int session_input(void *data, int length);
void session_poll(void **data, int *length);
void session_ack(int length);
void session_ack_consumed(int length);
void session_ack_sent(int length);
#endif /* __SESSION_H */