$ git clone https://ion.nu/git/webchat
commit 5c9d7c607a1a246205bd7e9f566d2a64ff9b6fe6
Author: Alicia <...>
Date: Wed Jan 6 21:15:49 2016 +0100
If there is data in gnutls's buffers, keep reading (or start reading regardless of incoming data from the network)
diff --git a/src/chat.c b/src/chat.c
index 667621b..e76e2b3 100644
--- a/src/chat.c
+++ b/src/chat.c
@@ -124,7 +124,7 @@ printf("New connection\n");
}
for(i=0; i<usercount; ++i)
{
- if(!fds[i+1].revents){continue;}
+ if(!fds[i+1].revents && (!use_tls || !gnutls_record_check_pending(users[i]->socket))){continue;}
if(fds[i+1].revents&(POLLERR|POLLHUP|POLLNVAL))
{
if(users[i]->channel)
@@ -241,7 +241,7 @@ printf("User %u disconnected\n", i);
break;
}
users[i]->packet.data=malloc(users[i]->packet.head.length+1);
- continue;
+ if(!use_tls || !gnutls_record_check_pending(users[i]->socket)){continue;}
}
if(!websock_readcontent(users[i]->socket, users[i]->packet.data, &users[i]->packet.head, use_tls)){continue;} // Handle other sessions while waiting for the rest of the packet
#define head users[i]->packet.head