Skip to content

Commit 984ced6

Browse files
committed
o Used more significant variables names
o Preparation work for use of Virtual Thread
1 parent 0407383 commit 984ced6

File tree

1 file changed

+76
-9
lines changed
  • protocol-ldap/src/main/java/org/apache/directory/server/ldap

1 file changed

+76
-9
lines changed

protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222

2323
import java.io.IOException;
24+
import java.net.Socket;
2425
import java.security.KeyStore;
2526
import java.util.ArrayList;
2627
import java.util.Collection;
@@ -399,11 +400,11 @@ public void reloadSslContext() throws Exception
399400
}
400401
}
401402

402-
StartTlsHandler handler = ( StartTlsHandler ) getExtendedOperationHandler( StartTlsHandler.EXTENSION_OID );
403+
StartTlsHandler startTlsHandler = ( StartTlsHandler ) getExtendedOperationHandler( StartTlsHandler.EXTENSION_OID );
403404

404-
if ( handler != null )
405+
if ( startTlsHandler != null )
405406
{
406-
handler.setLdapServer( this );
407+
startTlsHandler.setLdapServer( this );
407408
}
408409

409410
LOG.info( "reloaded SSL context successfully" );
@@ -610,6 +611,72 @@ public void stop()
610611
started = false;
611612
LOG.info( "Ldap service stopped." );
612613
}
614+
615+
/*
616+
private void startVTNetwork( Transport transport, IoFilterChainBuilder chainBuilder ) throws Exception
617+
{
618+
if ( transport.getBackLog() < 0 )
619+
{
620+
// Set the backlog to the default value when it's below 0
621+
transport.setBackLog( 50 );
622+
}
623+
624+
if ( transport instanceof TcpTransport )
625+
{
626+
try ( ServerSocket serverSocket = new ServerSocket(
627+
transport.getPort(),
628+
transport.getBackLog(),
629+
InetAddress.getByName( transport.getAddress() ) ) )
630+
{
631+
serverSocket.setOption( StandardSocketOptions.SO_REUSEADDR, true );
632+
serverSocket.setOption( StandardSocketOptions.SO_REUSEPORT, true );
633+
serverSocket.setOption( StandardSocketOptions.SO_RCVBUF, 64 * 1024 );
634+
//serverSocket.setOption( StandardSocketOptions.SO_SNDBUF, 64 * 1024 );
635+
//serverSocket.setOption( StandardSocketOptions.TCP_NODELAY, true );
636+
637+
Runnable ldapServer = () ->
638+
{
639+
System.out.println( "Hello LDAP Serevr!" );
640+
641+
while ( true )
642+
{
643+
Socket socket;
644+
645+
try
646+
{
647+
socket = serverSocket.accept();
648+
649+
Thread.Builder builder = Thread.ofVirtual()
650+
.name( "virtual thread" )
651+
.inheritInheritableThreadLocals( false )
652+
.uncaughtExceptionHandler( ( t, e ) -> System.out.printf( "thread %s failed with exception %s", t, e ) );
653+
654+
Thread thread = builder.unstarted( () -> System.out.println( "run" ) );
655+
}
656+
catch ( IOException e )
657+
{
658+
e.printStackTrace();
659+
String msg = I18n.err( I18n.ERR_38009_FAILED_TO_BIND_TO_SERVICE_REGISTRY, transport.getPort() );
660+
LdapConfigurationException lce = new LdapConfigurationException( msg );
661+
lce.setCause( e );
662+
LOG.error( msg, e );
663+
}
664+
}
665+
};
666+
667+
Thread thread = Thread.startVirtualThread( ldapServer );
668+
669+
System.out.println( "Daemon: " + thread.isDaemon() );
670+
}
671+
}
672+
}
673+
*/
674+
675+
676+
private void handleLdapRequest( Socket socket )
677+
{
678+
679+
}
613680

614681

615682
private void startNetwork( Transport transport, IoFilterChainBuilder chainBuilder ) throws Exception
@@ -816,18 +883,18 @@ public void removeExtendedOperationHandler( String oid )
816883
// DefaultPartitionNexus nexus = getDirectoryService().getPartitionNexus();
817884
// nexus.unregisterSupportedExtensions( eoh.getExtensionOids() );
818885

819-
ExtendedOperationHandler<?, ?> handler = null;
886+
ExtendedOperationHandler<?, ?> removedExtendedOperationHandler = null;
820887

821888
for ( ExtendedOperationHandler<?, ?> extendedOperationHandler : extendedOperationHandlers )
822889
{
823890
if ( extendedOperationHandler.getOid().equals( oid ) )
824891
{
825-
handler = extendedOperationHandler;
892+
removedExtendedOperationHandler = extendedOperationHandler;
826893
break;
827894
}
828895
}
829896

830-
extendedOperationHandlers.remove( handler );
897+
extendedOperationHandlers.remove( removedExtendedOperationHandler );
831898
}
832899

833900

@@ -837,7 +904,7 @@ public void removeExtendedOperationHandler( String oid )
837904
*
838905
* @param oid the oid of the extended request of associated with the extended
839906
* request handler
840-
* @return the exnteded operation handler
907+
* @return the extended operation handler
841908
*/
842909
public ExtendedOperationHandler<? extends ExtendedRequest, ? extends ExtendedResponse> getExtendedOperationHandler(
843910
String oid )
@@ -1064,9 +1131,9 @@ public void setSaslMechanismHandlers( Map<String, MechanismHandler> saslMechanis
10641131
}
10651132

10661133

1067-
public MechanismHandler addSaslMechanismHandler( String mechanism, MechanismHandler handler )
1134+
public MechanismHandler addSaslMechanismHandler( String mechanism, MechanismHandler mechanislHandler )
10681135
{
1069-
return this.saslMechanismHandlers.put( mechanism, handler );
1136+
return this.saslMechanismHandlers.put( mechanism, mechanislHandler );
10701137
}
10711138

10721139

0 commit comments

Comments
 (0)