switch (sofar) {
case -1 : //trouble to write
switch (status=SSL_get_error(tls->ssl,-1)) {
- case SSL_ERROR_WANT_READ : //"wanted" error
- case SSL_ERROR_WANT_WRITE :
+ case SSL_ERROR_WANT_READ : //
+ case SSL_ERROR_WANT_WRITE : //"Wanted" error
(void) printf("JMPDBG SSL_get_error='%d'\n",status);
(void) usleep(1000);
count++;
PUBLIC int tls_read(TLSTYP *tls,char *buffer,int maxread)
{
+#define OPEP "unitls.c:tls_read"
+
int got;
got=-1;
if (tls!=(TLSTYP *)0) {
- if ((got=SSL_read(tls->ssl,buffer,maxread))<0) {
- (void) showtlserror(tls,got,"Trouble to read data");
- got=-1;
+ _Bool proceed;
+ int count;
+
+ count=0;
+ proceed=true;
+
+ (void) printf("JMPDBG receiving\n");
+ while (proceed==true) {
+ int status;
+
+ proceed=false;
+ got=SSL_read(tls->ssl,buffer,maxread);
+ (void) printf("JMPDBG read got='%d' count='%d'\n",got,count);
+ switch (got) {
+ case -1 : //trouble to write
+ switch (status=SSL_get_error(tls->ssl,-1)) {
+ case SSL_ERROR_WANT_READ : //"wanted" error
+ case SSL_ERROR_WANT_WRITE : //
+ (void) printf("JMPDBG SSL_get_error='%d'\n",status);
+ (void) usleep(1000);
+ break;
+ default :
+ (void) showtlserror(tls,-1,"%s Premature EOF with crypted link",OPEP);
+ break;
+ }
+ break;
+ case 0 : //no char sent
+ switch (SSL_get_error(tls->ssl,0)) {
+ case SSL_ERROR_SYSCALL : //EOF received?
+ tls->goteof=true;
+ if (ERR_get_error()!=0)
+ (void) rou_alert(0,"%s wrong EOF",OPEP);
+ break;
+ default :
+ (void) rou_alert(0,"%s Unexpected SSL_read error='%d'",
+ OPEP,SSL_get_error(tls->ssl,0));
+ (void) showtlserror(tls,0,"show SSL error",OPEP);
+ break;
+ }
+ break;
+ default : //some character received
+ break;
+ }
}
}
return got;
+#undef OPEP
}
/*
^L