Commit b49932d6 authored by Ondřej Kuzník's avatar Ondřej Kuzník Committed by Ondřej Kuzník
Browse files

Connection write support

parent 79f7e79f
......@@ -42,6 +42,24 @@ void
client_write_cb( evutil_socket_t s, short what, void *arg )
{
Connection *c = arg;
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
Debug( LDAP_DEBUG_CONNS, "client_write_cb: "
"have something to write to client %lu\n",
c->c_connid );
if ( ber_flush( c->c_sb, c->c_pendingber, 1 ) ) {
int err = sock_errno();
if ( err != EWOULDBLOCK && err != EAGAIN ) {
ldap_pvt_thread_mutex_lock( &c->c_mutex );
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
client_destroy( c );
return;
}
event_add( c->c_write_event, NULL );
}
c->c_pendingber = NULL;
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
}
Connection *
......
......@@ -285,8 +285,8 @@ struct Connection {
ldap_pvt_thread_mutex_t c_io_mutex; /* only one pdu written at a time */
BerElement *c_currentber; /* ber we're attempting to read */
struct berval c_pendingber; /* ber we're attempting to write */
BerElement *c_currentber; /* ber we're attempting to read */
BerElement *c_pendingber; /* ber we're attempting to write */
#define CONN_IS_TLS 1
#define CONN_IS_CLIENT 4
......
......@@ -39,6 +39,27 @@ void
upstream_write_cb( evutil_socket_t s, short what, void *arg )
{
Connection *c = arg;
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
Debug( LDAP_DEBUG_CONNS, "upstream_write_cb: "
"have something to write to upstream %lu\n",
c->c_connid );
if ( ber_flush( c->c_sb, c->c_pendingber, 1 ) ) {
int err = sock_errno();
if ( err != EWOULDBLOCK && err != EAGAIN ) {
ldap_pvt_thread_mutex_lock( &c->c_mutex );
Debug( LDAP_DEBUG_ANY, "upstream_write_cb: "
"error writing to connection %ld\n",
c->c_connid );
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
upstream_destroy( c );
return;
}
event_add( c->c_write_event, 0 );
}
c->c_pendingber = NULL;
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
}
Connection *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment