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 );
53 static void connection_destroy( Connection *c );
61 * Initialize connection management infrastructure.
63 int connections_init(void)
65 assert( connections == NULL );
67 if( connections != NULL) {
68 Debug( LDAP_DEBUG_ANY, "connections_init: already initialized.\n",
73 /* should check return of every call */
74 ldap_pvt_thread_mutex_init( &connections_mutex );
76 connections = (Connection *) calloc( dtblsize, sizeof(Connection) );
78 if( connections == NULL ) {
79 Debug( LDAP_DEBUG_ANY,
80 "connections_init: allocation (%d*%ld) of connection array failed.\n",
81 dtblsize, (long) sizeof(Connection), 0 );
85 assert( connections[0].c_struct_state == SLAP_C_UNINITIALIZED );
86 assert( connections[dtblsize-1].c_struct_state == SLAP_C_UNINITIALIZED );
89 * per entry initialization of the Connection array initialization
90 * will be done by connection_init()
97 * Destroy connection management infrastructure.
99 int connections_destroy(void)
103 /* should check return of every call */
105 if( connections == NULL) {
106 Debug( LDAP_DEBUG_ANY, "connections_destroy: nothing to destroy.\n",
111 for ( i = 0; i < dtblsize; i++ ) {
112 if( connections[i].c_struct_state != SLAP_C_UNINITIALIZED ) {
113 ldap_pvt_thread_mutex_destroy( &connections[i].c_mutex );
114 ldap_pvt_thread_mutex_destroy( &connections[i].c_write_mutex );
115 ldap_pvt_thread_cond_destroy( &connections[i].c_write_cv );
122 ldap_pvt_thread_mutex_destroy( &connections_mutex );
127 * shutdown all connections
129 int connections_shutdown(void)
133 ldap_pvt_thread_mutex_lock( &connections_mutex );
135 for ( i = 0; i < dtblsize; i++ ) {
136 if( connections[i].c_struct_state != SLAP_C_USED ) {
140 ldap_pvt_thread_mutex_lock( &connections[i].c_mutex );
142 /* connections_mutex and c_mutex are locked */
143 connection_closing( &connections[i] );
144 connection_close( &connections[i] );
146 ldap_pvt_thread_mutex_unlock( &connections[i].c_mutex );
149 ldap_pvt_thread_mutex_unlock( &connections_mutex );
155 * Timeout idle connections.
157 int connections_timeout_idle(time_t now)
163 ldap_pvt_thread_mutex_lock( &connections_mutex );
165 for( c = connection_first( &connindex );
167 c = connection_next( c, &connindex ) )
169 if( difftime( c->c_activitytime+global_idletimeout, now) < 0 ) {
171 connection_closing( c );
172 connection_close( c );
176 connection_done( c );
178 ldap_pvt_thread_mutex_unlock( &connections_mutex );
183 static Connection* connection_get( ber_socket_t s )
185 /* connections_mutex should be locked by caller */
189 Debug( LDAP_DEBUG_ARGS,
190 "connection_get(%ld)\n",
193 assert( connections != NULL );
195 if(s == AC_SOCKET_INVALID) {
202 assert( c->c_struct_state != SLAP_C_UNINITIALIZED );
209 for(i=0; i<dtblsize; i++) {
210 if( connections[i].c_struct_state == SLAP_C_UNINITIALIZED ) {
211 assert( connections[i].c_conn_state == SLAP_C_INVALID );
212 assert( connections[i].c_sb == 0 );
216 if( connections[i].c_struct_state == SLAP_C_UNUSED ) {
217 assert( connections[i].c_conn_state == SLAP_C_INVALID );
218 assert( !ber_pvt_sb_in_use( connections[i].c_sb ) );
222 /* state can actually change from used -> unused by resched,
223 * so don't assert details here.
226 if( ber_pvt_sb_get_desc( connections[i].c_sb ) == s ) {
235 ldap_pvt_thread_mutex_lock( &c->c_mutex );
237 if( c->c_struct_state != SLAP_C_USED ) {
238 /* connection must have been closed due to resched */
240 assert( c->c_conn_state == SLAP_C_INVALID );
241 assert( !ber_pvt_sb_in_use( c->c_sb ) );
243 Debug( LDAP_DEBUG_TRACE,
244 "connection_get(%d): connection not used.\n",
247 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
251 Debug( LDAP_DEBUG_TRACE,
252 "connection_get(%d): got connid=%ld\n",
257 assert( c->c_struct_state == SLAP_C_USED );
258 assert( c->c_conn_state != SLAP_C_INVALID );
259 assert( ber_pvt_sb_in_use( c->c_sb ) );
261 c->c_activitytime = slap_get_time();
267 static void connection_return( Connection *c )
269 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
272 long connection_init(
280 assert( connections != NULL );
282 if( s == AC_SOCKET_INVALID ) {
283 Debug( LDAP_DEBUG_ANY,
284 "connection_init(%ld): invalid.\n",
291 assert( s < dtblsize );
294 ldap_pvt_thread_mutex_lock( &connections_mutex );
305 for( i=0; i < dtblsize; i++) {
306 if( connections[i].c_struct_state == SLAP_C_UNINITIALIZED ) {
307 assert( connections[i].c_sb == 0 );
312 if( connections[i].c_struct_state == SLAP_C_UNUSED ) {
313 assert( !ber_pvt_sb_in_use( connections[i].c_sb ));
318 assert( connections[i].c_struct_state == SLAP_C_USED );
319 assert( connections[i].c_conn_state != SLAP_C_INVALID );
320 assert( ber_pvt_sb_in_use( connections[i].c_sb ));
324 Debug( LDAP_DEBUG_ANY,
325 "connection_init(%d): connection table full (%d/%d).\n",
327 ldap_pvt_thread_mutex_unlock( &connections_mutex );
334 assert( c->c_struct_state != SLAP_C_USED );
335 assert( c->c_conn_state == SLAP_C_INVALID );
337 if( c->c_struct_state == SLAP_C_UNINITIALIZED ) {
340 c->c_client_name = NULL;
341 c->c_client_addr = NULL;
343 c->c_pending_ops = NULL;
344 c->c_authmech = NULL;
345 c->c_authstate = NULL;
347 c->c_sb = ber_sockbuf_alloc( );
349 /* should check status of thread calls */
350 ldap_pvt_thread_mutex_init( &c->c_mutex );
351 ldap_pvt_thread_mutex_init( &c->c_write_mutex );
352 ldap_pvt_thread_cond_init( &c->c_write_cv );
354 c->c_struct_state = SLAP_C_UNUSED;
357 ldap_pvt_thread_mutex_lock( &c->c_mutex );
359 assert( c->c_struct_state == SLAP_C_UNUSED );
360 assert( c->c_dn == NULL );
361 assert( c->c_cdn == NULL );
362 assert( c->c_client_name == NULL );
363 assert( c->c_client_addr == NULL );
364 assert( c->c_ops == NULL );
365 assert( c->c_pending_ops == NULL );
366 assert( c->c_authmech == NULL );
367 assert( c->c_authstate == NULL );
369 c->c_client_name = ch_strdup( name == NULL ? "" : name );
370 c->c_client_addr = ch_strdup( addr );
372 c->c_n_ops_received = 0;
373 c->c_n_ops_executing = 0;
374 c->c_n_ops_pending = 0;
375 c->c_n_ops_completed = 0;
381 c->c_activitytime = c->c_starttime = slap_get_time();
383 ber_pvt_sb_set_desc( c->c_sb, s );
384 ber_pvt_sb_set_io( c->c_sb, &ber_pvt_sb_io_tcp, NULL );
386 if( ber_pvt_sb_set_nonblock( c->c_sb, 1 ) < 0 ) {
387 Debug( LDAP_DEBUG_ANY,
388 "connection_init(%d, %s, %s): set nonblocking failed\n",
389 s, c->c_client_name, c->c_client_addr);
392 id = c->c_connid = conn_nextid++;
394 c->c_conn_state = SLAP_C_INACTIVE;
395 c->c_struct_state = SLAP_C_USED;
399 /* FIXME: >0 means incomplete read */
400 if ( ldap_pvt_tls_accept( c->c_sb, NULL ) < 0 ) {
401 Debug( LDAP_DEBUG_ANY,
402 "connection_init(%d): TLS accept failed.\n",
404 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
405 ldap_pvt_thread_mutex_unlock( &connections_mutex );
406 connection_destroy( c );
412 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
413 ldap_pvt_thread_mutex_unlock( &connections_mutex );
415 backend_connection_init(c);
421 connection_destroy( Connection *c )
423 /* note: connections_mutex should be locked by caller */
425 assert( connections != NULL );
427 assert( c->c_struct_state != SLAP_C_UNUSED );
428 assert( c->c_conn_state != SLAP_C_INVALID );
429 assert( c->c_ops == NULL );
431 backend_connection_destroy(c);
435 c->c_activitytime = c->c_starttime = 0;
437 if(c->c_dn != NULL) {
441 if(c->c_cdn != NULL) {
445 if(c->c_client_name != NULL) {
446 free(c->c_client_name);
447 c->c_client_name = NULL;
449 if(c->c_client_addr != NULL) {
450 free(c->c_client_addr);
451 c->c_client_addr = NULL;
453 if(c->c_authmech != NULL ) {
455 c->c_authmech = NULL;
457 if(c->c_authstate != NULL ) {
458 free(c->c_authstate);
459 c->c_authstate = NULL;
462 if ( ber_pvt_sb_in_use(c->c_sb) ) {
463 int sd = ber_pvt_sb_get_desc(c->c_sb);
465 slapd_remove( sd, 0 );
466 ber_pvt_sb_close( c->c_sb );
468 Statslog( LDAP_DEBUG_STATS,
469 "conn=%d fd=%d closed.\n",
470 c->c_connid, sd, 0, 0, 0 );
473 ber_pvt_sb_destroy( c->c_sb );
475 c->c_conn_state = SLAP_C_INVALID;
476 c->c_struct_state = SLAP_C_UNUSED;
479 int connection_state_closing( Connection *c )
481 /* c_mutex must be locked by caller */
485 assert( c->c_struct_state == SLAP_C_USED );
487 state = c->c_conn_state;
489 assert( state != SLAP_C_INVALID );
491 return state == SLAP_C_CLOSING;
494 static void connection_abandon( Connection *c )
496 /* c_mutex must be locked by caller */
500 for( o = c->c_ops; o != NULL; o = o->o_next ) {
501 ldap_pvt_thread_mutex_lock( &o->o_abandonmutex );
503 ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex );
506 /* remove pending operations */
507 for( o = slap_op_pop( &c->c_pending_ops );
509 o = slap_op_pop( &c->c_pending_ops ) )
515 void connection_closing( Connection *c )
517 assert( connections != NULL );
519 assert( c->c_struct_state == SLAP_C_USED );
520 assert( c->c_conn_state != SLAP_C_INVALID );
522 /* c_mutex must be locked by caller */
524 if( c->c_conn_state != SLAP_C_CLOSING ) {
526 Debug( LDAP_DEBUG_TRACE,
527 "connection_closing: readying conn=%ld sd=%d for close.\n",
528 c->c_connid, ber_pvt_sb_get_desc( c->c_sb ), 0 );
530 /* update state to closing */
531 c->c_conn_state = SLAP_C_CLOSING;
533 /* don't listen on this port anymore */
534 slapd_clr_read( ber_pvt_sb_get_desc( c->c_sb ), 1 );
536 /* shutdown I/O -- not yet implemented */
538 /* abandon active operations */
539 connection_abandon( c );
541 /* wake write blocked operations */
542 slapd_clr_write( ber_pvt_sb_get_desc(c->c_sb), 1 );
543 ldap_pvt_thread_cond_signal( &c->c_write_cv );
547 static void connection_close( Connection *c )
549 assert( connections != NULL );
551 assert( c->c_struct_state == SLAP_C_USED );
552 assert( c->c_conn_state == SLAP_C_CLOSING );
554 /* note: connections_mutex and c_mutex should be locked by caller */
556 if( c->c_ops != NULL ) {
557 Debug( LDAP_DEBUG_TRACE,
558 "connection_close: deferring conn=%ld sd=%d.\n",
559 c->c_connid, ber_pvt_sb_get_desc( c->c_sb ), 0 );
564 Debug( LDAP_DEBUG_TRACE, "connection_close: conn=%ld sd=%d.\n",
565 c->c_connid, ber_pvt_sb_get_desc( c->c_sb ), 0 );
567 connection_destroy( c );
570 unsigned long connections_nextid(void)
573 assert( connections != NULL );
575 ldap_pvt_thread_mutex_lock( &connections_mutex );
579 ldap_pvt_thread_mutex_unlock( &connections_mutex );
584 Connection* connection_first( ber_socket_t *index )
586 assert( connections != NULL );
587 assert( index != NULL );
589 ldap_pvt_thread_mutex_lock( &connections_mutex );
593 return connection_next(NULL, index);
596 Connection* connection_next( Connection *c, ber_socket_t *index )
598 assert( connections != NULL );
599 assert( index != NULL );
600 assert( *index <= dtblsize );
603 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
608 for(; *index < dtblsize; (*index)++) {
609 if( connections[*index].c_struct_state == SLAP_C_UNINITIALIZED ) {
610 assert( connections[*index].c_conn_state == SLAP_C_INVALID );
618 if( connections[*index].c_struct_state == SLAP_C_USED ) {
619 assert( connections[*index].c_conn_state != SLAP_C_INVALID );
620 c = &connections[(*index)++];
624 assert( connections[*index].c_struct_state == SLAP_C_UNUSED );
625 assert( connections[*index].c_conn_state == SLAP_C_INVALID );
629 ldap_pvt_thread_mutex_lock( &c->c_mutex );
635 void connection_done( Connection *c )
637 assert( connections != NULL );
640 ldap_pvt_thread_mutex_unlock( &c->c_mutex );
643 ldap_pvt_thread_mutex_unlock( &connections_mutex );
647 * connection_activity - handle the request operation op on connection
648 * conn. This routine figures out what kind of operation it is and
649 * calls the appropriate stub to handle it.
653 connection_operation( void *arg_v )
656 struct co_arg *arg = arg_v;
657 ber_tag_t tag = arg->co_op->o_tag;
658 Connection *conn = arg->co_conn;
660 ldap_pvt_thread_mutex_lock( &num_ops_mutex );
662 ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
666 rc = do_bind( conn, arg->co_op );
669 case LDAP_REQ_UNBIND:
670 rc = do_unbind( conn, arg->co_op );
674 rc = do_add( conn, arg->co_op );
677 case LDAP_REQ_DELETE:
678 rc = do_delete( conn, arg->co_op );
681 case LDAP_REQ_MODRDN:
682 rc = do_modrdn( conn, arg->co_op );
685 case LDAP_REQ_MODIFY:
686 rc = do_modify( conn, arg->co_op );
689 case LDAP_REQ_COMPARE:
690 rc = do_compare( conn, arg->co_op );
693 case LDAP_REQ_SEARCH:
694 rc = do_search( conn, arg->co_op );
697 case LDAP_REQ_ABANDON:
698 rc = do_abandon( conn, arg->co_op );
701 case LDAP_REQ_EXTENDED:
702 rc = do_extended( conn, arg->co_op );
706 Debug( LDAP_DEBUG_ANY, "unknown LDAP request 0x%lx\n",
708 arg->co_op->o_tag = LBER_ERROR;
709 send_ldap_disconnect( conn, arg->co_op,
710 LDAP_PROTOCOL_ERROR, "unknown LDAP request" );
715 if( rc == -1 ) tag = LBER_ERROR;
717 ldap_pvt_thread_mutex_lock( &num_ops_mutex );
719 ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
721 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
723 conn->c_n_ops_executing--;
724 conn->c_n_ops_completed++;
726 slap_op_remove( &conn->c_ops, arg->co_op );
727 slap_op_free( arg->co_op );
730 free( (char *) arg );
735 case LDAP_REQ_UNBIND:
736 /* c_mutex is locked */
737 connection_closing( conn );
741 if( conn->c_conn_state == SLAP_C_BINDING) {
742 conn->c_conn_state = SLAP_C_ACTIVE;
744 conn->c_bind_in_progress = ( rc == LDAP_SASL_BIND_IN_PROGRESS );
747 ldap_pvt_thread_mutex_lock( &active_threads_mutex );
749 if( active_threads < 1 ) {
750 ldap_pvt_thread_cond_signal(&active_threads_cond);
752 ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
754 connection_resched( conn );
756 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
761 int connection_read(ber_socket_t s)
765 assert( connections != NULL );
767 ldap_pvt_thread_mutex_lock( &connections_mutex );
769 /* get (locked) connection */
770 c = connection_get( s );
773 Debug( LDAP_DEBUG_ANY,
774 "connection_read(%ld): no connection!\n",
779 ldap_pvt_thread_mutex_unlock( &connections_mutex );
785 if( c->c_conn_state == SLAP_C_CLOSING ) {
786 Debug( LDAP_DEBUG_TRACE,
787 "connection_read(%d): closing, ignoring input for id=%ld\n",
790 connection_return( c );
791 ldap_pvt_thread_mutex_unlock( &connections_mutex );
795 Debug( LDAP_DEBUG_TRACE,
796 "connection_read(%d): checking for input on id=%ld\n",
799 #define CONNECTION_INPUT_LOOP 1
801 #ifdef DATA_READY_LOOP
802 while(!rc && ber_pvt_sb_data_ready(&c->c_sb))
803 #elif CONNECTION_INPUT_LOOP
807 rc = connection_input( c );
811 Debug( LDAP_DEBUG_TRACE,
812 "connection_read(%d): input error=%d id=%ld, closing.\n",
813 s, rc, c->c_connid );
815 /* connections_mutex and c_mutex are locked */
816 connection_closing( c );
817 connection_close( c );
820 connection_return( c );
821 ldap_pvt_thread_mutex_unlock( &connections_mutex );
836 if ( conn->c_currentber == NULL && (conn->c_currentber = ber_alloc())
838 Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
843 if ( (tag = ber_get_next( conn->c_sb, &len, conn->c_currentber ))
844 != LDAP_TAG_MESSAGE )
848 Debug( LDAP_DEBUG_TRACE,
849 "ber_get_next on fd %d failed errno %d (%s)\n",
850 ber_pvt_sb_get_desc( conn->c_sb ), err,
851 err > -1 && err < sys_nerr ? sys_errlist[err] : "unknown" );
852 Debug( LDAP_DEBUG_TRACE,
853 "\t*** got %ld of %lu so far\n",
854 (long)(conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf),
855 conn->c_currentber->ber_len, 0 );
857 if ( err != EWOULDBLOCK && err != EAGAIN ) {
858 /* log, close and send error */
859 ber_free( conn->c_currentber, 1 );
860 conn->c_currentber = NULL;
867 ber = conn->c_currentber;
868 conn->c_currentber = NULL;
870 if ( (tag = ber_get_int( ber, &msgid )) != LDAP_TAG_MSGID ) {
871 /* log, close and send error */
872 Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%lx\n", tag, 0,
878 if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
879 /* log, close and send error */
880 Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%lx\n", tag, 0,
887 if(tag == LDAP_REQ_BIND) {
888 /* immediately abandon all exiting operations upon BIND */
889 connection_abandon( conn );
892 op = slap_op_alloc( ber, msgid, tag, conn->c_n_ops_received++ );
894 if ( conn->c_conn_state == SLAP_C_BINDING
895 || conn->c_conn_state == SLAP_C_CLOSING )
897 Debug( LDAP_DEBUG_ANY, "deferring operation\n", 0, 0, 0 );
898 conn->c_n_ops_pending++;
899 slap_op_add( &conn->c_pending_ops, op );
902 conn->c_n_ops_executing++;
903 connection_op_activate( conn, op );
907 if ( conn->c_struct_state != SLAP_C_USED ) {
908 /* connection must have got closed underneath us */
912 assert( conn->c_struct_state == SLAP_C_USED );
918 connection_resched( Connection *conn )
922 if( conn->c_conn_state == SLAP_C_CLOSING ) {
923 Debug( LDAP_DEBUG_TRACE,
924 "connection_resched: attempting closing conn=%ld sd=%d.\n",
925 conn->c_connid, ber_pvt_sb_get_desc( conn->c_sb ), 0 );
927 connection_close( conn );
931 if( conn->c_conn_state != SLAP_C_ACTIVE ) {
932 /* other states need different handling */
936 for( op = slap_op_pop( &conn->c_pending_ops );
938 op = slap_op_pop( &conn->c_pending_ops ) )
940 /* pending operations should not be marked for abandonment */
941 assert(!op->o_abandon);
943 conn->c_n_ops_pending--;
944 conn->c_n_ops_executing++;
946 connection_op_activate( conn, op );
948 if ( conn->c_conn_state == SLAP_C_BINDING ) {
955 static int connection_op_activate( Connection *conn, Operation *op )
960 ber_tag_t tag = op->o_tag;
962 if(tag == LDAP_REQ_BIND) {
963 conn->c_conn_state = SLAP_C_BINDING;
966 if ( conn->c_dn != NULL ) {
967 tmpdn = ch_strdup( conn->c_dn );
972 arg = (struct co_arg *) ch_malloc( sizeof(struct co_arg) );
976 arg->co_op->o_bind_in_progress = conn->c_bind_in_progress;
978 arg->co_op->o_dn = ch_strdup( tmpdn != NULL ? tmpdn : "" );
979 arg->co_op->o_ndn = dn_normalize_case( ch_strdup( arg->co_op->o_dn ) );
981 arg->co_op->o_protocol = conn->c_protocol;
983 arg->co_op->o_authtype = conn->c_authtype;
984 arg->co_op->o_authmech = conn->c_authmech != NULL
985 ? ch_strdup( conn->c_authmech ) : NULL;
987 slap_op_add( &conn->c_ops, arg->co_op );
989 if( tmpdn != NULL ) {
993 ldap_pvt_thread_mutex_lock( &active_threads_mutex );
995 ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
997 status = ldap_pvt_thread_create( &arg->co_op->o_tid, 1,
998 connection_operation, (void *) arg );
1000 if ( status != 0 ) {
1001 Debug( LDAP_DEBUG_ANY,
1002 "ldap_pvt_thread_create failed (%d)\n", status, 0, 0 );
1004 /* should move op to pending list */
1010 int connection_write(ber_socket_t s)
1013 assert( connections != NULL );
1015 ldap_pvt_thread_mutex_lock( &connections_mutex );
1017 c = connection_get( s );
1019 slapd_clr_write( s, 0);
1022 Debug( LDAP_DEBUG_ANY,
1023 "connection_write(%ld): no connection!\n",
1026 ldap_pvt_thread_mutex_unlock( &connections_mutex );
1032 Debug( LDAP_DEBUG_TRACE,
1033 "connection_write(%d): waking output for id=%ld\n",
1034 s, c->c_connid, 0 );
1036 ldap_pvt_thread_cond_signal( &c->c_write_cv );
1038 connection_return( c );
1039 ldap_pvt_thread_mutex_unlock( &connections_mutex );