RECORD_LAYER_write_pending.
Reviewed-by: Richard Levitte <levitte@openssl.org>
#define RECORD_LAYER_get_wrec(rl) (&(rl)->wrec)
void RECORD_LAYER_clear(RECORD_LAYER *rl);
+void RECORD_LAYER_release(RECORD_LAYER *rl);
+int RECORD_LAYER_read_pending(RECORD_LAYER *rl);
+int RECORD_LAYER_write_pending(RECORD_LAYER *rl);
__owur int ssl23_read_bytes(SSL *s, int n);
__owur int ssl23_write_bytes(SSL *s);
__owur int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
rl->s = s;
}
+void RECORD_LAYER_release(RECORD_LAYER *rl)
+{
+ if (SSL3_BUFFER_is_initialised(&rl->rbuf))
+ ssl3_release_read_buffer(rl->s);
+ if (SSL3_BUFFER_is_initialised(&rl->wbuf))
+ ssl3_release_write_buffer(rl->s);
+ SSL3_RECORD_release(&rl->rrec);
+}
+
+int RECORD_LAYER_read_pending(RECORD_LAYER *rl)
+{
+ return SSL3_BUFFER_get_left(&rl->rbuf) != 0;
+}
+
+int RECORD_LAYER_write_pending(RECORD_LAYER *rl)
+{
+ return SSL3_BUFFER_get_left(&rl->wbuf) != 0;
+}
+
int ssl3_read_n(SSL *s, int n, int max, int extend)
{
/*
int ret = 0;
if (s->s3->renegotiate) {
- if ((SSL3_BUFFER_get_left(RECORD_LAYER_get_rbuf(&s->rlayer)) == 0)
- && (SSL3_BUFFER_get_left(RECORD_LAYER_get_wbuf(&s->rlayer)) == 0)
+ if (!RECORD_LAYER_read_pending(&s->rlayer)
+ && !RECORD_LAYER_write_pending(&s->rlayer)
&& !SSL_in_init(s)) {
/*
* if we are the server, and we have sent a 'RENEGOTIATE'
s->s3->alert_dispatch = 1;
s->s3->send_alert[0] = level;
s->s3->send_alert[1] = desc;
- if (SSL3_BUFFER_get_left(RECORD_LAYER_get_wbuf(&s->rlayer)) == 0) {
+ if (!RECORD_LAYER_write_pending(&s->rlayer)) {
/* data still being written out? */
return s->method->ssl_dispatch_alert(s);
}
if (s->method != NULL)
s->method->ssl_free(s);
- if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer)))
- ssl3_release_read_buffer(s);
- if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_wbuf(&s->rlayer)))
- ssl3_release_write_buffer(s);
- SSL3_RECORD_release(RECORD_LAYER_get_rrec(&s->rlayer));
+ RECORD_LAYER_release(&s->rlayer);
if (s->ctx)
SSL_CTX_free(s->ctx);