Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@ protected void procSMBServerElement(Element smb)
if ( findChildNode( "disableNIO", smb.getChildNodes()) != null)
smbConfig.setDisableNIOCode( true);

// Check if the HashedOpenFileMap should be disabled (and ArrayOpenFileMap used
// instead)
if (findChildNode("disableHashedOpenFileMap", smb.getChildNodes()) != null)
smbConfig.setDisableHashedOpenFileMap(true);

// Check if a maximum virtual circuits per session limit has been specified
elem = findChildNode("virtualCircuits", smb.getChildNodes());
if ( elem != null) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/filesys/server/config/ConfigId.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class ConfigId {
public static final int SMBRequireSigning = GroupSMB + 33;
public static final int SMBSocketKeepAlive = GroupSMB + 34;
public static final int SMBPacketsPerThreadRun = GroupSMB + 35;
public static final int SMBDisableHashedOFM = GroupSMB + 36;

// FTP server variables
public static final int FTPBindAddress = GroupFTP + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ public class ArrayOpenFileMapIterator implements Iterator<Integer> {

@Override
public boolean hasNext() {
while ( m_files[ m_nextId] == null && m_nextId < m_files.length)
while (m_nextId < m_files.length && m_files[m_nextId] == null)
m_nextId++;

return m_nextId < m_files.length;
}

@Override
public Integer next() {
while ( m_files[ m_nextId] == null && m_nextId < m_files.length)
while (m_nextId < m_files.length && m_files[m_nextId] == null)
m_nextId++;

if ( m_nextId < m_files.length)
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/org/filesys/server/filesys/TreeConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import org.filesys.server.SrvSession;
import org.filesys.server.auth.ISMBAuthenticator;
import org.filesys.server.auth.acl.AccessControl;
import org.filesys.server.config.ServerConfiguration;
import org.filesys.server.core.DeviceContext;
import org.filesys.server.core.DeviceInterface;
import org.filesys.server.core.InvalidDeviceInterfaceException;
import org.filesys.server.core.SharedDevice;
import org.filesys.smb.server.SMBConfigSection;
import org.filesys.smb.server.SMBSrvSession;

import java.util.Iterator;
Expand Down Expand Up @@ -67,7 +69,7 @@ public TreeConnection(SharedDevice shrDev) {
m_shareDev = shrDev;
m_shareDev.incrementConnectionCount();

m_files = new HashedOpenFileMap();
m_files = getOpenFileMap(shrDev.getConfiguration());
}

/**
Expand All @@ -82,9 +84,21 @@ public TreeConnection(SharedDevice shrDev, int treeId) {

m_treeId = treeId;

m_files = new HashedOpenFileMap();
m_files = getOpenFileMap(shrDev.getConfiguration());
}

private OpenFileMap getOpenFileMap(ServerConfiguration config) {
if (config != null) {
SMBConfigSection smbConfig = (SMBConfigSection) config.getConfigSection(SMBConfigSection.SectionName);
if (smbConfig != null)
if (smbConfig.hasDisableHashedOpenFileMap()) {
return new ArrayOpenFileMap();
}
}

return new HashedOpenFileMap();
}

/**
* Return the tree id
*
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/org/filesys/smb/server/SMBConfigSection.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public class SMBConfigSection extends ConfigSection {
// Per session virtual circuit limit
private int m_virtualCircuitLimit = SMBV1VirtualCircuitList.DefMaxCircuits;

// Use ArrayOpenFileMap instead of HashedOpenFileMap
private boolean m_disableHashedOpenFileMap;

//--------------------------------------------------------------------------------
// Win32 NetBIOS configuration
//
Expand Down Expand Up @@ -655,6 +658,15 @@ public final boolean isNativeCodeDisabled() {
return m_disableNativeCode;
}

/**
* Determine if the HashedOpenFileMap should be disabled
*
* @return boolean
*/
public final boolean hasDisableHashedOpenFileMap() {
return m_disableHashedOpenFileMap;
}

/**
* Set the authenticator to be used to authenticate users and share connections.
*
Expand Down Expand Up @@ -1494,6 +1506,24 @@ public final int setMaximumPacketsPerThreadRun(int maxPkts)
*/
public final void setForestName(String forestName) { m_forestName = forestName; }

/**
* Set the disable HashedOpenFileMap flag
*
* @param disableHashedOFM boolean
* @return int
* @throws InvalidConfigurationException Failed to set the disable
* HashedOpenFileMap flag
*/
public final int setDisableHashedOpenFileMap(boolean disableHashedOFM) throws InvalidConfigurationException {

// Inform listeners, validate the configuration change
int sts = fireConfigurationChange(ConfigId.SMBDisableHashedOFM, new Boolean(disableHashedOFM));
m_disableHashedOpenFileMap = disableHashedOFM;

// Return the change status
return sts;
}

/**
* Close the configuration section
*/
Expand Down