Commit 924046ce authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Make non blocking I/O work for accept BIOs.

parent 9e2c0f41
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -4,6 +4,13 @@

 Changes between 0.9.6 and 0.9.7  [xx XXX 2000]

  *) Fix for non blocking accept BIOs. Added new I/O special reason
     BIO_RR_ACCEPT to cover this case. Previously use of accept BIOs
     with non blocking I/O was not possible because no retry code was
     implemented. Also added new SSL code SSL_WANT_ACCEPT to cover
     this case.
     [Steve Henson]

  *) Fix for bug in DirectoryString mask setting. Add support for
     X509_NAME_print_ex() in 'req' and X509_print_ex() function
     to allow certificate printing to more controllable, additional
+1 −0
Original line number Diff line number Diff line
@@ -661,6 +661,7 @@ int BIO_accept(int sock, char **addr)
	ret=accept(sock,(struct sockaddr *)&from,(void *)&len);
	if (ret == INVALID_SOCKET)
		{
		if(BIO_sock_should_retry(ret)) return -2;
		SYSerr(SYS_F_ACCEPT,get_last_socket_error());
		BIOerr(BIO_F_BIO_ACCEPT,BIO_R_ACCEPT_ERROR);
		goto end;
+3 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ extern "C" {
#define BIO_retry_type(a)		((a)->flags & BIO_FLAGS_RWS)
#define BIO_should_retry(a)		((a)->flags & BIO_FLAGS_SHOULD_RETRY)

/* The next two are used in conjunction with the
/* The next three are used in conjunction with the
 * BIO_should_io_special() condition.  After this returns true,
 * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO 
 * stack and return the 'reason' for the special and the offending BIO.
@@ -188,6 +188,8 @@ extern "C" {
#define BIO_RR_SSL_X509_LOOKUP		0x01
/* Returned from the connect BIO when a connect would have blocked */
#define BIO_RR_CONNECT			0x02
/* Returned from the accept BIO when an accept would have blocked */
#define BIO_RR_ACCEPT			0x03

/* These are passed by the BIO callback */
#define BIO_CB_FREE	0x01
+12 −0
Original line number Diff line number Diff line
@@ -236,8 +236,20 @@ again:
			c->state=ACPT_S_OK;
			goto again;
			}
		BIO_clear_retry_flags(b);
		b->retry_reason=0;
		i=BIO_accept(c->accept_sock,&(c->addr));

		/* -2 return means we should retry */
		if(i == -2)
			{
			BIO_set_retry_special(b);
			b->retry_reason=BIO_RR_ACCEPT;
			return -1;
			}

		if (i < 0) return(i);

		bio=BIO_new_socket(i,BIO_CLOSE);
		if (bio == NULL) goto err;

+8 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ BIO_do_accept() serves two functions. When it is first
called, after the accept BIO has been setup, it will attempt
to create the accept socket and bind an address to it. Second
and subsequent calls to BIO_do_accept() will await an incoming
connection.
connection, or request a retry in non blocking mode.

=head1 NOTES

@@ -130,6 +130,13 @@ however because the accept BIO will still accept additional incoming
connections. This can be resolved by using BIO_pop() (see above)
and freeing up the accept BIO after the initial connection.

If the underlying accept socket is non blocking and BIO_do_accept() is
called to await an incoming connection it is possible for
BIO_should_io_special() with the reason BIO_RR_ACCEPT. If this happens
then it is an indication that an accept attempt would block: the application
should take appropriate action to wait until the underlying socket has
accepted a connection and retry the call.

=head1 RETURN VALUES

TBA
Loading