From dc65ef038279df55d5e49052eabac4eae2617ee1 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Wed, 14 Dec 2016 09:14:39 -0500 Subject: Now compiles with Turbo C 2.0 using included makefile. Added better logging (to screen). Added supprot for opening and sending gzip'ed files if available on disk. --- uip/psock.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'uip/psock.c') diff --git a/uip/psock.c b/uip/psock.c index 95ad542..8f2a83b 100644 --- a/uip/psock.c +++ b/uip/psock.c @@ -144,6 +144,7 @@ buf_bufto(register struct psock_buf *buf, u8_t endmarker, static char send_data(register struct psock *s) { + if(s->state != STATE_DATA_SENT || uip_rexmit()) { if(s->sendlen > uip_mss()) { uip_send(s->sendptr, uip_mss()); @@ -172,6 +173,18 @@ data_acked(register struct psock *s) } return 0; } + +static char send_and_ack(register struct psock *s) +{ +char sent; +char ack; + + ack = data_acked(s); + sent = send_data(s); + + return ack && sent; +} + /*---------------------------------------------------------------------------*/ PT_THREAD(psock_send(register struct psock *s, const char *buf, unsigned int len)) @@ -193,7 +206,6 @@ PT_THREAD(psock_send(register struct psock *s, const char *buf, /* We loop here until all data is sent. The s->sendlen variable is updated by the data_sent() function. */ while(s->sendlen > 0) { - /* * The condition for this PT_WAIT_UNTIL is a little tricky: the * protothread will wait here until all data has been acknowledged @@ -204,7 +216,9 @@ PT_THREAD(psock_send(register struct psock *s, const char *buf, * && operator, which would cause only the data_acked() function * to be called when it returns false. */ - PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s)); + + /* PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s)); */ + PT_WAIT_UNTIL(&s->psockpt, send_and_ack(s)); } s->state = STATE_NONE; @@ -235,7 +249,8 @@ PT_THREAD(psock_generator_send(register struct psock *s, generate(arg); } /* Wait until all data is sent and acknowledged. */ - PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s)); + /* PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s)); */ + PT_WAIT_UNTIL(&s->psockpt, send_and_ack(s)); } while(s->sendlen > 0); s->state = STATE_NONE; -- cgit v1.2.3