ValidSession valid_connection; /* true or FALSE - if this session is valid */
- int may_read; /* if it's 0 then we can read/write, otherwise it's forbiden to read/write
+ int may_not_read; /* if it's 0 then we can read/write, otherwise it's forbiden to read/write
*/
- int may_write;
+ int may_not_write;
+ int read_eof; /* non-zero if we have received a closure alert. */
int last_alert; /* last alert received */
case STATE62:
if ( how == GNUTLS_SHUT_RDWR) {
ret = _gnutls_recv_int( session, GNUTLS_ALERT, -1, NULL, 0);
- if (ret >= 0) session->internals.may_read = 1;
+ if (ret >= 0) session->internals.may_not_read = 1;
}
STATE = STATE62;
STATE = STATE0;
- session->internals.may_write = 1;
+ session->internals.may_not_write = 1;
return 0;
}
}
if (type!=GNUTLS_ALERT) /* alert messages are sent anyway */
- if ( _gnutls_session_is_valid( session) || session->internals.may_write != 0) {
+ if ( _gnutls_session_is_valid( session) || session->internals.may_not_write != 0) {
gnutls_assert();
return GNUTLS_E_INVALID_SESSION;
}
if (data[1] == GNUTLS_A_CLOSE_NOTIFY && data[0] != GNUTLS_AL_FATAL) {
/* If we have been expecting for an alert do
*/
-
+ session->internals.read_eof = 1;
return GNUTLS_E_INT_RET_0; /* EOF */
} else {
return GNUTLS_E_TOO_MANY_EMPTY_PACKETS;
}
- if ( _gnutls_session_is_valid(session)!=0 || session->internals.may_read!=0) {
+ if (session->internals.read_eof != 0) {
+ /* if we have already read an EOF
+ */
+ return 0;
+ } else if ( _gnutls_session_is_valid(session)!=0 || session->internals.may_not_read!=0) {
gnutls_assert();
return GNUTLS_E_INVALID_SESSION;
}