Fix bug # 263557 - Sending a request fails on Windows when the

ber size is larger than 64MB.
  Break up large messages into <= 8MB sized chunks inside prldap_write().
This commit is contained in:
mcs%pearlcrescent.com 2004-10-15 13:10:04 +00:00
parent 1ea5ef52b0
commit 862ceba0a0
2 changed files with 36 additions and 5 deletions

View File

@ -61,6 +61,15 @@
*/
#define PRLDAP_DEFAULT_ADDRESS_FAMILY PR_AF_INET6
/*
* Max length for sending message with one PR_Send.
* If a single message is larger than this size, the message is divided
* into multiple pieces up to this length and sent out. This is necessary
* on Microsoft Windows at least where attempts to send really large
* messages in one PR_Send() call result in an error.
*/
#define PRLDAP_MAX_SEND_SIZE (8*1024*1024) /* 8MB */
/*
* Data structures:

View File

@ -198,15 +198,37 @@ prldap_write( int s, const void *buf, int len,
struct lextiof_socket_private *socketarg )
{
PRIntervalTime prit;
char *ptr = (char *)buf;
int rest = len;
prit = prldap_timeout2it( LDAP_X_IO_TIMEOUT_NO_TIMEOUT,
socketarg->prsock_io_max_timeout );
/*
* Note the 4th parameter (flags) to PR_Send() has been obsoleted and
* must always be 0
*/
return( PR_Send( PRLDAP_GET_PRFD(socketarg), buf, len, 0, prit ));
while ( rest > 0 ) {
int rval;
if ( rest > PRLDAP_MAX_SEND_SIZE ) {
len = PRLDAP_MAX_SEND_SIZE;
} else {
len = rest;
}
/*
* Note the 4th parameter (flags) to PR_Send() has been obsoleted and
* must always be 0
*/
rval = PR_Send( PRLDAP_GET_PRFD(socketarg), ptr, len, 0, prit );
if ( 0 > rval ) {
return rval;
}
if ( 0 == rval ) {
break;
}
ptr += rval;
rest -= rval;
}
return (int)( ptr - (char *)buf );
}