new control code BIO_C_RESET_READ_REQUEST
authorBodo Möller <bodo@openssl.org>
Mon, 27 Sep 1999 13:43:59 +0000 (13:43 +0000)
committerBodo Möller <bodo@openssl.org>
Mon, 27 Sep 1999 13:43:59 +0000 (13:43 +0000)
crypto/bio/bio.h
crypto/bio/bss_bio.c

index a05e0c2eacdb7eb8aaecf9f46d13b5ca364aeaef..d9a6f6913fd7c626f5190a6251e5d075f771c12a 100644 (file)
@@ -334,6 +334,7 @@ typedef struct bio_f_buffer_ctx_struct
 #define BIO_C_NREAD                            144
 #define BIO_C_NWRITE0                          145
 #define BIO_C_NWRITE                           146
+#define BIO_C_RESET_READ_REQUEST               147
 
 
 #define BIO_set_app_data(s,arg)                BIO_set_ex_data(s,0,(char *)arg)
@@ -470,6 +471,7 @@ size_t BIO_ctrl_wpending(BIO *b);
 #define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
 size_t BIO_ctrl_get_write_guarantee(BIO *b);
 size_t BIO_ctrl_get_read_request(BIO *b);
+int BIO_ctrl_reset_read_request(BIO *b);
 
 #ifdef NO_STDIO
 #define NO_FP_API
index ef4b3454d79be1c2ac67997f6ddf9d9f3614912d..40df575af9752329de9dd0a2642c3a61dd485608 100644 (file)
@@ -493,6 +493,15 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
                ret = (long) b->request;
                break;
 
+       case BIO_C_RESET_READ_REQUEST:
+               /* Reset request.  (Can be useful after read attempts
+                * at the other side that are meant to be non-blocking,
+                * e.g. when probing SSL_read to see if any data is
+                * available.) */
+               b->request = 0;
+               ret = 1;
+               break;
+
        case BIO_C_SHUTDOWN_WR:
                /* similar to shutdown(..., SHUT_WR) */
                b->closed = 1;
@@ -750,6 +759,11 @@ size_t BIO_ctrl_get_read_request(BIO *bio)
        return BIO_ctrl(bio, BIO_C_GET_READ_REQUEST, 0, NULL);
        }
 
+int BIO_ctrl_reset_read_request(BIO *bio)
+       {
+       return (BIO_ctrl(bio, BIO_C_RESET_READ_REQUEST, 0, NULL) != 0);
+       }
+
 
 /* BIO_nread0/nread/nwrite0/nwrite are availabe only for BIO pairs for now
  * (conceivably some other BIOs could allow non-copying reads and writes too.)