remove invalid error handling due to enhancements

pull/146/head
kaleb-himes 2019-04-19 10:04:18 -06:00
parent dbb1246d78
commit 6a3416f3e5
1 changed files with 9 additions and 20 deletions

View File

@ -95,22 +95,18 @@ void* ClientHandler(void* args)
printf("Client %d connected successfully\n", pkg->num);
/* Read the client data into our buff array */
memset(buff, 0, sizeof(buff));
while (wolfSSL_want_read(ssl) || XSTRLEN(buff) == 0) {
ret = wolfSSL_read(ssl, buff, sizeof(buff)-1);
}
if (ret <= 0) {
fprintf(stderr, "ret = %d\n", ret);
fprintf(stderr, "ERROR: failed to read\n");
pkg->open = 1;
pthread_exit(NULL);
/* TODO: Currently this thread can get stuck infinitely if client
* disconnects, add timer to abort on a timeout eventually,
* just an example for now so allow for possible stuck condition
*/
}
/* Print to stdout any data the client sends */
printf("Client %d said: %s <--------------------------------------------\n",
pkg->num, buff);
printf("Client %d said: %s\n", pkg->num, buff);
/* Check for server shutdown command */
if (strncmp(buff, "shutdown", 8) == 0) {
@ -118,8 +114,6 @@ void* ClientHandler(void* args)
*pkg->shutdown = 1;
}
/* Write our reply into buff */
memset(buff, 0, sizeof(buff));
memcpy(buff, reply, strlen(reply));
@ -128,16 +122,11 @@ void* ClientHandler(void* args)
/* Reply back to the client */
while (wolfSSL_want_write(ssl) || ret < len) {
ret = wolfSSL_write(ssl, buff, len);
/* TODO: Currently this thread can get stuck infinitely if client
* disconnects, add timer to abort on a timeout eventually,
* just an example for now so allow for possible stuck condition
*/
}
if (ret < len) {
fprintf(stderr, "Wrote %d bytes but expected to write %d bytes\n",
ret, (int) len);
fprintf(stderr, "ERROR: failed to write\n");
pkg->open = 1;
pthread_exit(NULL);
}
/* Cleanup after this connection */
wolfSSL_free(ssl); /* Free the wolfSSL object */