13 /* we need LBER internals */
14 #include "../../libraries/liblber/lber-int.h"
16 /* protected by connections_mutex */
17 static ldap_pvt_thread_mutex_t connections_mutex;
18 static Connection *connections = NULL;
19 static unsigned long conn_nextid = 0;
21 /* structure state (protected by connections_mutex) */
22 #define SLAP_C_UNINITIALIZED 0x00 /* MUST BE ZERO (0) */
23 #define SLAP_C_UNUSED 0x01
24 #define SLAP_C_USED 0x02
26 /* connection state (protected by c_mutex ) */
27 #define SLAP_C_INVALID 0x00 /* MUST BE ZERO (0) */
28 #define SLAP_C_INACTIVE 0x01 /* zero threads */
29 #define SLAP_C_ACTIVE 0x02 /* one or more threads */
30 #define SLAP_C_BINDING 0x03 /* binding */
31 #define SLAP_C_CLOSING 0x04 /* closing */
33 char* connection_state2str( int state ) {
35 case SLAP_C_INVALID: return "!";
36 case SLAP_C_INACTIVE: return "|";
37 case SLAP_C_ACTIVE: return "";
38 case SLAP_C_BINDING: return "B";
39 case SLAP_C_CLOSING: return "C";
45 static Connection* connection_get( ber_socket_t s );
47 static int connection_input( Connection *c );
48 static void connection_close( Connection *c );
50 static int connection_op_activate( Connection *conn, Operation *op );
51 static int connection_resched( Connection *conn );
52 static void connection_abandon( Connection *conn );
60 * Initialize connection management infrastructure.
62 int connections_init(void)
64 assert( connections == NULL );
66 if( connections != NULL) {
67 Debug( LDAP_DEBUG_ANY, "connections_init: already initialized.\n",
72 /* should check return of every call */
73 ldap_pvt_thread_mutex_init( &connections_mutex );
75 connections = (Connection *) calloc( dtblsize, sizeof(Connection) );
77 if( connections == NULL ) {
78 Debug( LDAP_DEBUG_ANY,
79 "connections_init: allocation (%d*%ld) of connection array failed.\n",
80 dtblsize, (long) sizeof(Connection), 0 );
84 assert( connections[0].c_struct_state == SLAP_C_UNINITIALIZED );
85 assert( connections[dtblsize-1].c_struct_state == SLAP_C_UNINITIALIZED );
88 * per entry initialization of the Connection array initialization
89 * will be done by connection_init()
96 * Destroy connection management infrastructure.
98 int connections_destroy(void)
102 /* should check return of every call */
104 if( connections == NULL) {
105 Debug( LDAP_DEBUG_ANY, "connections_destroy: nothing to destroy.\n",
110 for ( i = 0; i < dtblsize; i++ ) {
111 if( connections[i].c_struct_state != SLAP_C_UNINITIALIZED ) {
112 ldap_pvt_thread_mutex_destroy( &connections[i].c_mutex );
113 ldap_pvt_thread_mutex_destroy( &connections[i].c_write_mutex );
114 ldap_pvt_thread_cond_destroy( &connections[i].c_write_cv );
121 ldap_pvt_thread_mutex_destroy( &connections_mutex );
126 * shutdown all connections
128 int connections_shutdown(void)
132 ldap_pvt_thread_mutex_lock( &connections_mutex );
134 for ( i = 0; i < dtblsize; i++ ) {
135 if( connections[i].c_struct_state != SLAP_C_USED ) {
139 ldap_pvt_thread_mutex_lock( &connections[i].c_mutex );
141 /* connections_mutex and c_mutex are locked */
142 connection_closing( &connections[i] );
143 connection_close( &connections[i] );
145 ldap_pvt_thread_mutex_unlock( &connections[i].c_mutex );
148 ldap_pvt_thread_mutex_unlock( &connections_mutex );
154 * Timeout idle connections.
156 int connections_timeout_idle(time_t now)
162 ldap_pvt_thread_mutex_lock( &connections_mutex );
164 for( c = connection_first( &connindex );
166 c = connection_next( c, &connindex ) )
168 if( difftime( c->c_activitytime+global_idletimeout, now) < 0 ) {
170 connection_closing( c );
171 connection_close( c );
175 connection_done( c );
177 ldap_pvt_thread_mutex_unlock( &connections_mutex );
182 static Connection* connection_get( ber_socket_t s )
184 /* connections_mutex should be locked by caller */
188 Debug( LDAP_DEBUG_ARGS,
189 "connection_get(%ld)\n",
192 assert( connections != NULL );
194 if(s == AC_SOCKET_INVALID) {
201 assert( c->c_struct_state != SLAP_C_UNINITIALIZED );
208 for(i=0; i<dtblsize; i++) {
209 if( connections[i].c_struct_state == SLAP_C_UNINITIALIZED ) {
210 assert( connections[i].c_conn_state == SLAP_C_INVALID );
211 assert( connections[i].c_sb == 0 );
215 if( connections[i].c_struct_state == SLAP_C_UNUSED ) {
216 assert( connections[i].c_conn_state == SLAP_C_INVALID );
217 assert( !ber_pvt_sb_in_use( connections[i].c_sb ) );
221 /* state can actually change from used -> unused by resched,
222 * so don't assert details here.
225 if( ber_pvt_sb_get_desc( connections[i].c_sb ) == s ) {
234 ldap_pvt_thread_mutex_lock( &c->c_mutex );
236 if( c->c_struct_state != SLAP_C_USED ) {
237 /* connection must have been closed due to resched */
239 assert( c->c_conn_state == SLAP_C_INVALID );
240 assert( !ber_pvt_sb_in_use( c->c_sb ) );
242 Debug( LDAP_DEBUG_TRACE,
243 "connection_get(%d): connection not used.\n",
246 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
250 Debug( LDAP_DEBUG_TRACE,
251 "connection_get(%d): got connid=%ld\n",
256 assert( c->c_struct_state == SLAP_C_USED );
257 assert( c->c_conn_state != SLAP_C_INVALID );
258 assert( ber_pvt_sb_in_use( c->c_sb ) );
260 c->c_activitytime = slap_get_time();
266 static void connection_return( Connection *c )
268 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
271 long connection_init(
278 assert( connections != NULL );
280 if( s == AC_SOCKET_INVALID ) {
281 Debug( LDAP_DEBUG_ANY,
282 "connection_init(%ld): invalid.\n",
289 assert( s < dtblsize );
292 ldap_pvt_thread_mutex_lock( &connections_mutex );
303 for( i=0; i < dtblsize; i++) {
304 if( connections[i].c_struct_state == SLAP_C_UNINITIALIZED ) {
305 assert( connections[i].c_sb == 0 );
310 if( connections[i].c_struct_state == SLAP_C_UNUSED ) {
311 assert( !ber_pvt_sb_in_use( connections[i].c_sb ));
316 assert( connections[i].c_struct_state == SLAP_C_USED );
317 assert( connections[i].c_conn_state != SLAP_C_INVALID );
318 assert( ber_pvt_sb_in_use( connections[i].c_sb ));
322 Debug( LDAP_DEBUG_ANY,
323 "connection_init(%d): connection table full (%d/%d).\n",
325 ldap_pvt_thread_mutex_unlock( &connections_mutex );
332 assert( c->c_struct_state != SLAP_C_USED );
333 assert( c->c_conn_state == SLAP_C_INVALID );
335 if( c->c_struct_state == SLAP_C_UNINITIALIZED ) {
338 c->c_client_name = NULL;
339 c->c_client_addr = NULL;
341 c->c_pending_ops = NULL;
342 c->c_authmech = NULL;
343 c->c_authstate = NULL;
345 c->c_sb = ber_sockbuf_alloc( );
347 /* should check status of thread calls */
348 ldap_pvt_thread_mutex_init( &c->c_mutex );
349 ldap_pvt_thread_mutex_init( &c->c_write_mutex );
350 ldap_pvt_thread_cond_init( &c->c_write_cv );
352 c->c_struct_state = SLAP_C_UNUSED;
355 ldap_pvt_thread_mutex_lock( &c->c_mutex );
357 assert( c->c_struct_state == SLAP_C_UNUSED );
358 assert( c->c_dn == NULL );
359 assert( c->c_cdn == NULL );
360 assert( c->c_client_name == NULL );
361 assert( c->c_client_addr == NULL );
362 assert( c->c_ops == NULL );
363 assert( c->c_pending_ops == NULL );
364 assert( c->c_authmech == NULL );
365 assert( c->c_authstate == NULL );
367 c->c_client_name = ch_strdup( name == NULL ? "" : name );
368 c->c_client_addr = ch_strdup( addr );
370 c->c_n_ops_received = 0;
371 c->c_n_ops_executing = 0;
372 c->c_n_ops_pending = 0;
373 c->c_n_ops_completed = 0;
379 c->c_activitytime = c->c_starttime = slap_get_time();
381 ber_pvt_sb_set_desc( c->c_sb, s );
382 ber_pvt_sb_set_io( c->c_sb, &ber_pvt_sb_io_tcp, NULL );
384 if( ber_pvt_sb_set_nonblock( c->c_sb, 1 ) < 0 ) {
385 Debug( LDAP_DEBUG_ANY,
386 "connection_init(%d, %s, %s): set nonblocking failed\n",
387 s, c->c_client_name, c->c_client_addr);
390 id = c->c_connid = conn_nextid++;
392 c->c_conn_state = SLAP_C_INACTIVE;
393 c->c_struct_state = SLAP_C_USED;
395 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
396 ldap_pvt_thread_mutex_unlock( &connections_mutex );
398 backend_connection_init(c);
404 connection_destroy( Connection *c )
406 /* note: connections_mutex should be locked by caller */
408 assert( connections != NULL );
410 assert( c->c_struct_state != SLAP_C_UNUSED );
411 assert( c->c_conn_state != SLAP_C_INVALID );
412 assert( c->c_ops == NULL );
414 backend_connection_destroy(c);
418 c->c_activitytime = c->c_starttime = 0;
420 if(c->c_dn != NULL) {
424 if(c->c_cdn != NULL) {
428 if(c->c_client_name != NULL) {
429 free(c->c_client_name);
430 c->c_client_name = NULL;
432 if(c->c_client_addr != NULL) {
433 free(c->c_client_addr);
434 c->c_client_addr = NULL;
436 if(c->c_authmech != NULL ) {
438 c->c_authmech = NULL;
440 if(c->c_authstate != NULL ) {
441 free(c->c_authstate);
442 c->c_authstate = NULL;
445 if ( ber_pvt_sb_in_use(c->c_sb) ) {
446 int sd = ber_pvt_sb_get_desc(c->c_sb);
448 slapd_remove( sd, 0 );
449 ber_pvt_sb_close( c->c_sb );
451 Statslog( LDAP_DEBUG_STATS,
452 "conn=%d fd=%d closed.\n",
453 c->c_connid, sd, 0, 0, 0 );
456 ber_pvt_sb_destroy( c->c_sb );
458 c->c_conn_state = SLAP_C_INVALID;
459 c->c_struct_state = SLAP_C_UNUSED;
462 int connection_state_closing( Connection *c )
464 /* c_mutex must be locked by caller */
468 assert( c->c_struct_state == SLAP_C_USED );
470 state = c->c_conn_state;
472 assert( state != SLAP_C_INVALID );
474 return state == SLAP_C_CLOSING;
477 static void connection_abandon( Connection *c )
479 /* c_mutex must be locked by caller */
483 for( o = c->c_ops; o != NULL; o = o->o_next ) {
484 ldap_pvt_thread_mutex_lock( &o->o_abandonmutex );
486 ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex );
489 /* remove pending operations */
490 for( o = slap_op_pop( &c->c_pending_ops );
492 o = slap_op_pop( &c->c_pending_ops ) )
498 void connection_closing( Connection *c )
500 assert( connections != NULL );
502 assert( c->c_struct_state == SLAP_C_USED );
503 assert( c->c_conn_state != SLAP_C_INVALID );
505 /* c_mutex must be locked by caller */
507 if( c->c_conn_state != SLAP_C_CLOSING ) {
509 Debug( LDAP_DEBUG_TRACE,
510 "connection_closing: readying conn=%ld sd=%d for close.\n",
511 c->c_connid, ber_pvt_sb_get_desc( c->c_sb ), 0 );
513 /* update state to closing */
514 c->c_conn_state = SLAP_C_CLOSING;
516 /* don't listen on this port anymore */
517 slapd_clr_read( ber_pvt_sb_get_desc( c->c_sb ), 1 );
519 /* shutdown I/O -- not yet implemented */
521 /* abandon active operations */
522 connection_abandon( c );
524 /* wake write blocked operations */
525 slapd_clr_write( ber_pvt_sb_get_desc(c->c_sb), 1 );
526 ldap_pvt_thread_cond_signal( &c->c_write_cv );
530 static void connection_close( Connection *c )
532 assert( connections != NULL );
534 assert( c->c_struct_state == SLAP_C_USED );
535 assert( c->c_conn_state == SLAP_C_CLOSING );
537 /* note: connections_mutex and c_mutex should be locked by caller */
539 if( c->c_ops != NULL ) {
540 Debug( LDAP_DEBUG_TRACE,
541 "connection_close: deferring conn=%ld sd=%d.\n",
542 c->c_connid, ber_pvt_sb_get_desc( c->c_sb ), 0 );
547 Debug( LDAP_DEBUG_TRACE, "connection_close: conn=%ld sd=%d.\n",
548 c->c_connid, ber_pvt_sb_get_desc( c->c_sb ), 0 );
550 connection_destroy( c );
553 unsigned long connections_nextid(void)
556 assert( connections != NULL );
558 ldap_pvt_thread_mutex_lock( &connections_mutex );
562 ldap_pvt_thread_mutex_unlock( &connections_mutex );
567 Connection* connection_first( ber_socket_t *index )
569 assert( connections != NULL );
570 assert( index != NULL );
572 ldap_pvt_thread_mutex_lock( &connections_mutex );
576 return connection_next(NULL, index);
579 Connection* connection_next( Connection *c, ber_socket_t *index )
581 assert( connections != NULL );
582 assert( index != NULL );
583 assert( *index <= dtblsize );
586 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
591 for(; *index < dtblsize; (*index)++) {
592 if( connections[*index].c_struct_state == SLAP_C_UNINITIALIZED ) {
593 assert( connections[*index].c_conn_state == SLAP_C_INVALID );
601 if( connections[*index].c_struct_state == SLAP_C_USED ) {
602 assert( connections[*index].c_conn_state != SLAP_C_INVALID );
603 c = &connections[(*index)++];
607 assert( connections[*index].c_struct_state == SLAP_C_UNUSED );
608 assert( connections[*index].c_conn_state == SLAP_C_INVALID );
612 ldap_pvt_thread_mutex_lock( &c->c_mutex );
618 void connection_done( Connection *c )
620 assert( connections != NULL );
623 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
626 ldap_pvt_thread_mutex_unlock( &connections_mutex );
630 * connection_activity - handle the request operation op on connection
631 * conn. This routine figures out what kind of operation it is and
632 * calls the appropriate stub to handle it.
636 connection_operation( void *arg_v )
639 struct co_arg *arg = arg_v;
640 ber_tag_t tag = arg->co_op->o_tag;
641 Connection *conn = arg->co_conn;
643 ldap_pvt_thread_mutex_lock( &num_ops_mutex );
645 ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
649 rc = do_bind( conn, arg->co_op );
652 case LDAP_REQ_UNBIND:
653 rc = do_unbind( conn, arg->co_op );
657 rc = do_add( conn, arg->co_op );
660 case LDAP_REQ_DELETE:
661 rc = do_delete( conn, arg->co_op );
664 case LDAP_REQ_MODRDN:
665 rc = do_modrdn( conn, arg->co_op );
668 case LDAP_REQ_MODIFY:
669 rc = do_modify( conn, arg->co_op );
672 case LDAP_REQ_COMPARE:
673 rc = do_compare( conn, arg->co_op );
676 case LDAP_REQ_SEARCH:
677 rc = do_search( conn, arg->co_op );
680 case LDAP_REQ_ABANDON:
681 rc = do_abandon( conn, arg->co_op );
684 case LDAP_REQ_EXTENDED:
685 rc = do_extended( conn, arg->co_op );
689 Debug( LDAP_DEBUG_ANY, "unknown LDAP request 0x%lx\n",
691 arg->co_op->o_tag = LBER_ERROR;
692 send_ldap_disconnect( conn, arg->co_op,
693 LDAP_PROTOCOL_ERROR, "unknown LDAP request" );
698 if( rc == -1 ) tag = LBER_ERROR;
700 ldap_pvt_thread_mutex_lock( &num_ops_mutex );
702 ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
704 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
706 conn->c_n_ops_executing--;
707 conn->c_n_ops_completed++;
709 slap_op_remove( &conn->c_ops, arg->co_op );
710 slap_op_free( arg->co_op );
713 free( (char *) arg );
718 case LDAP_REQ_UNBIND:
719 /* c_mutex is locked */
720 connection_closing( conn );
724 if( conn->c_conn_state == SLAP_C_BINDING) {
725 conn->c_conn_state = SLAP_C_ACTIVE;
727 conn->c_bind_in_progress = ( rc == LDAP_SASL_BIND_IN_PROGRESS );
730 ldap_pvt_thread_mutex_lock( &active_threads_mutex );
732 if( active_threads < 1 ) {
733 ldap_pvt_thread_cond_signal(&active_threads_cond);
735 ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
737 connection_resched( conn );
739 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
744 int connection_read(ber_socket_t s)
748 assert( connections != NULL );
750 ldap_pvt_thread_mutex_lock( &connections_mutex );
752 /* get (locked) connection */
753 c = connection_get( s );
756 Debug( LDAP_DEBUG_ANY,
757 "connection_read(%ld): no connection!\n",
762 ldap_pvt_thread_mutex_unlock( &connections_mutex );
768 if( c->c_conn_state == SLAP_C_CLOSING ) {
769 Debug( LDAP_DEBUG_TRACE,
770 "connection_read(%d): closing, ignoring input for id=%ld\n",
773 connection_return( c );
774 ldap_pvt_thread_mutex_unlock( &connections_mutex );
778 Debug( LDAP_DEBUG_TRACE,
779 "connection_read(%d): checking for input on id=%ld\n",
782 #define CONNECTION_INPUT_LOOP 1
784 #ifdef DATA_READY_LOOP
785 while(!rc && ber_pvt_sb_data_ready(&c->c_sb))
786 #elif CONNECTION_INPUT_LOOP
790 rc = connection_input( c );
794 Debug( LDAP_DEBUG_TRACE,
795 "connection_read(%d): input error=%d id=%ld, closing.\n",
796 s, rc, c->c_connid );
798 /* connections_mutex and c_mutex are locked */
799 connection_closing( c );
800 connection_close( c );
803 connection_return( c );
804 ldap_pvt_thread_mutex_unlock( &connections_mutex );
819 if ( conn->c_currentber == NULL && (conn->c_currentber = ber_alloc())
821 Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
826 if ( (tag = ber_get_next( conn->c_sb, &len, conn->c_currentber ))
827 != LDAP_TAG_MESSAGE )
831 Debug( LDAP_DEBUG_TRACE,
832 "ber_get_next on fd %d failed errno %d (%s)\n",
833 ber_pvt_sb_get_desc( conn->c_sb ), err,
834 err > -1 && err < sys_nerr ? sys_errlist[err] : "unknown" );
835 Debug( LDAP_DEBUG_TRACE,
836 "\t*** got %ld of %lu so far\n",
837 (long)(conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf),
838 conn->c_currentber->ber_len, 0 );
840 if ( err != EWOULDBLOCK && err != EAGAIN ) {
841 /* log, close and send error */
842 ber_free( conn->c_currentber, 1 );
843 conn->c_currentber = NULL;
850 ber = conn->c_currentber;
851 conn->c_currentber = NULL;
853 if ( (tag = ber_get_int( ber, &msgid )) != LDAP_TAG_MSGID ) {
854 /* log, close and send error */
855 Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%lx\n", tag, 0,
861 if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
862 /* log, close and send error */
863 Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%lx\n", tag, 0,
870 if(tag == LDAP_REQ_BIND) {
871 /* immediately abandon all exiting operations upon BIND */
872 connection_abandon( conn );
875 op = slap_op_alloc( ber, msgid, tag, conn->c_n_ops_received++ );
877 if ( conn->c_conn_state == SLAP_C_BINDING
878 || conn->c_conn_state == SLAP_C_CLOSING )
880 Debug( LDAP_DEBUG_ANY, "deferring operation\n", 0, 0, 0 );
881 conn->c_n_ops_pending++;
882 slap_op_add( &conn->c_pending_ops, op );
885 conn->c_n_ops_executing++;
886 connection_op_activate( conn, op );
890 if ( conn->c_struct_state != SLAP_C_USED ) {
891 /* connection must have got closed underneath us */
895 assert( conn->c_struct_state == SLAP_C_USED );
901 connection_resched( Connection *conn )
905 if( conn->c_conn_state == SLAP_C_CLOSING ) {
906 Debug( LDAP_DEBUG_TRACE,
907 "connection_resched: attempting closing conn=%ld sd=%d.\n",
908 conn->c_connid, ber_pvt_sb_get_desc( conn->c_sb ), 0 );
910 connection_close( conn );
914 if( conn->c_conn_state != SLAP_C_ACTIVE ) {
915 /* other states need different handling */
919 for( op = slap_op_pop( &conn->c_pending_ops );
921 op = slap_op_pop( &conn->c_pending_ops ) )
923 /* pending operations should not be marked for abandonment */
924 assert(!op->o_abandon);
926 conn->c_n_ops_pending--;
927 conn->c_n_ops_executing++;
929 connection_op_activate( conn, op );
931 if ( conn->c_conn_state == SLAP_C_BINDING ) {
938 static int connection_op_activate( Connection *conn, Operation *op )
943 ber_tag_t tag = op->o_tag;
945 if(tag == LDAP_REQ_BIND) {
946 conn->c_conn_state = SLAP_C_BINDING;
949 if ( conn->c_dn != NULL ) {
950 tmpdn = ch_strdup( conn->c_dn );
955 arg = (struct co_arg *) ch_malloc( sizeof(struct co_arg) );
959 arg->co_op->o_bind_in_progress = conn->c_bind_in_progress;
961 arg->co_op->o_dn = ch_strdup( tmpdn != NULL ? tmpdn : "" );
962 arg->co_op->o_ndn = dn_normalize_case( ch_strdup( arg->co_op->o_dn ) );
964 arg->co_op->o_protocol = conn->c_protocol;
966 arg->co_op->o_authtype = conn->c_authtype;
967 arg->co_op->o_authmech = conn->c_authmech != NULL
968 ? ch_strdup( conn->c_authmech ) : NULL;
970 slap_op_add( &conn->c_ops, arg->co_op );
972 if( tmpdn != NULL ) {
976 ldap_pvt_thread_mutex_lock( &active_threads_mutex );
978 ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
980 status = ldap_pvt_thread_create( &arg->co_op->o_tid, 1,
981 connection_operation, (void *) arg );
984 Debug( LDAP_DEBUG_ANY,
985 "ldap_pvt_thread_create failed (%d)\n", status, 0, 0 );
987 /* should move op to pending list */
993 int connection_write(ber_socket_t s)
996 assert( connections != NULL );
998 ldap_pvt_thread_mutex_lock( &connections_mutex );
1000 c = connection_get( s );
1002 slapd_clr_write( s, 0);
1005 Debug( LDAP_DEBUG_ANY,
1006 "connection_write(%ld): no connection!\n",
1009 ldap_pvt_thread_mutex_unlock( &connections_mutex );
1015 Debug( LDAP_DEBUG_TRACE,
1016 "connection_write(%d): waking output for id=%ld\n",
1017 s, c->c_connid, 0 );
1019 ldap_pvt_thread_cond_signal( &c->c_write_cv );
1021 connection_return( c );
1022 ldap_pvt_thread_mutex_unlock( &connections_mutex );