Reset c_*ber after freeing and check c_pendingber race

This commit is contained in:
Ondřej Kuzník 2017-05-09 16:19:14 +01:00 committed by Ondřej Kuzník
parent 07b5744c2a
commit 77f2c57132
3 changed files with 6 additions and 2 deletions

View file

@ -210,7 +210,8 @@ client_write_cb( evutil_socket_t s, short what, void *arg )
"have something to write to client %lu\n",
c->c_connid );
if ( ber_flush( c->c_sb, c->c_pendingber, 1 ) ) {
/* We might have been beaten to flushing the data by another thread */
if ( c->c_pendingber && ber_flush( c->c_sb, c->c_pendingber, 1 ) ) {
int err = sock_errno();
if ( err != EWOULDBLOCK && err != EAGAIN ) {
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );

View file

@ -66,9 +66,11 @@ connection_destroy( Connection *c )
if ( c->c_currentber ) {
ber_free( c->c_currentber, 1 );
c->c_currentber = NULL;
}
if ( c->c_pendingber ) {
ber_free( c->c_pendingber, 1 );
c->c_pendingber = NULL;
}
CONNECTION_UNLOCK(c);

View file

@ -677,7 +677,8 @@ upstream_write_cb( evutil_socket_t s, short what, void *arg )
"have something to write to upstream %lu\n",
c->c_connid );
if ( ber_flush( c->c_sb, c->c_pendingber, 1 ) ) {
/* We might have been beaten to flushing the data by another thread */
if ( c->c_pendingber && ber_flush( c->c_sb, c->c_pendingber, 1 ) ) {
int err = sock_errno();
if ( err != EWOULDBLOCK && err != EAGAIN ) {
Debug( LDAP_DEBUG_ANY, "upstream_write_cb: "