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