From a05f525a7d5263b77b77b7fa79c61076e0ec5025 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Tue, 18 Jul 2006 15:08:26 +0000 Subject: [PATCH] Merged V1.3 to HEAD (3021:3026) svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3021 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3026 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3338 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../server/filesys/DiskDeviceContext.java | 6 ++- .../filesys/server/filesys/FileSystem.java | 23 ++++---- .../filesys/smb/mailslot/HostAnnouncer.java | 32 +++++++++++ .../mailslot/Win32NetBIOSHostAnnouncer.java | 36 ++++++++++++- .../mailslot/WinsockNetBIOSHostAnnouncer.java | 53 +++++++++++++++++-- .../filesys/smb/server/FindInfoPacker.java | 40 +++++++------- .../filesys/smb/server/SMBServer.java | 2 +- .../filesys/smb/server/SMBSrvSession.java | 2 +- .../smb/server/repo/ContentDiskDriver.java | 12 +---- 9 files changed, 158 insertions(+), 48 deletions(-) diff --git a/source/java/org/alfresco/filesys/server/filesys/DiskDeviceContext.java b/source/java/org/alfresco/filesys/server/filesys/DiskDeviceContext.java index 6bd50144dc..a4a108db7b 100644 --- a/source/java/org/alfresco/filesys/server/filesys/DiskDeviceContext.java +++ b/source/java/org/alfresco/filesys/server/filesys/DiskDeviceContext.java @@ -174,7 +174,11 @@ public class DiskDeviceContext extends DeviceContext */ public void CloseContext() { - + // Close the notify handler + + if ( hasChangeHandler()) + getChangeHandler().shutdownRequest(); + // Call the base class super.CloseContext(); diff --git a/source/java/org/alfresco/filesys/server/filesys/FileSystem.java b/source/java/org/alfresco/filesys/server/filesys/FileSystem.java index fb524ca33f..0776077075 100644 --- a/source/java/org/alfresco/filesys/server/filesys/FileSystem.java +++ b/source/java/org/alfresco/filesys/server/filesys/FileSystem.java @@ -28,17 +28,18 @@ public final class FileSystem // Filesystem attributes public static final int CaseSensitiveSearch = 0x00000001; - public static final int CasePreservedNames = 0x00000002; - public static final int UnicodeOnDisk = 0x00000004; - public static final int PersistentACLs = 0x00000008; - public static final int FileCompression = 0x00000010; - public static final int VolumeQuotas = 0x00000020; - public static final int SparseFiles = 0x00000040; - public static final int ReparsePoints = 0x00000080; - public static final int RemoteStorage = 0x00000100; - public static final int VolumeIsCompressed = 0x00008000; - public static final int ObjectIds = 0x00010000; - public static final int Encryption = 0x00020000; + public static final int CasePreservedNames = 0x00000002; + public static final int UnicodeOnDisk = 0x00000004; + public static final int PersistentACLs = 0x00000008; + public static final int FileCompression = 0x00000010; + public static final int VolumeQuotas = 0x00000020; + public static final int SparseFiles = 0x00000040; + public static final int ReparsePoints = 0x00000080; + public static final int RemoteStorage = 0x00000100; + public static final int LFNAPISupport = 0x00004000; + public static final int VolumeIsCompressed = 0x00008000; + public static final int ObjectIds = 0x00010000; + public static final int Encryption = 0x00020000; // Filesystem type strings diff --git a/source/java/org/alfresco/filesys/smb/mailslot/HostAnnouncer.java b/source/java/org/alfresco/filesys/smb/mailslot/HostAnnouncer.java index aa832c43da..415b4df160 100644 --- a/source/java/org/alfresco/filesys/smb/mailslot/HostAnnouncer.java +++ b/source/java/org/alfresco/filesys/smb/mailslot/HostAnnouncer.java @@ -75,6 +75,10 @@ public abstract class HostAnnouncer extends Thread private byte m_updateCount; + // Error count + + private int m_errorCount; + // Shutdown flag, host announcer should remove the announced name as it shuts down private boolean m_shutdown = false; @@ -156,6 +160,16 @@ public abstract class HostAnnouncer extends Thread return m_names.numberOfStrings(); } + /** + * Return the error count + * + * @return int + */ + protected final int getErrorCount() + { + return m_errorCount; + } + /** * Return the specified host name being announced. * @@ -493,6 +507,24 @@ public abstract class HostAnnouncer extends Thread m_srvtype = typ; } + /** + * Increment the error count + * + * @return int + */ + protected final int incrementErrorCount() + { + return ++m_errorCount; + } + + /** + * Clear the error count + */ + protected final void clearErrorCount() + { + m_errorCount = 0; + } + /** * Shutdown the host announcer and remove the announced name from Network Neighborhood. */ diff --git a/source/java/org/alfresco/filesys/smb/mailslot/Win32NetBIOSHostAnnouncer.java b/source/java/org/alfresco/filesys/smb/mailslot/Win32NetBIOSHostAnnouncer.java index 55ad8dedaa..b955c7191c 100644 --- a/source/java/org/alfresco/filesys/smb/mailslot/Win32NetBIOSHostAnnouncer.java +++ b/source/java/org/alfresco/filesys/smb/mailslot/Win32NetBIOSHostAnnouncer.java @@ -32,6 +32,10 @@ import org.alfresco.filesys.smb.server.win32.Win32NetBIOSSessionSocketHandler; public class Win32NetBIOSHostAnnouncer extends HostAnnouncer { + // Number of send errors before marking the LANA as offline + + private static final int SendErrorCount = 3; + // Associated session handler Win32NetBIOSSessionSocketHandler m_handler; @@ -120,6 +124,36 @@ public class Win32NetBIOSHostAnnouncer extends HostAnnouncer int sts = Win32NetBIOS.SendDatagram(getLana(), getNameNumber(), destName, buf, 0, len); if ( sts != NetBIOS.NRC_GoodRet) - logger.debug("Win32NetBIOS host announce error " + NetBIOS.getErrorString( -sts) + " (LANA " + getLana() + ")"); + { + // Log the error + + if ( logger.isErrorEnabled()) + logger.error("Host announce error " + NetBIOS.getErrorString( -sts) + + " (LANA " + getLana() + ")"); + + // Update the error count + + if ( incrementErrorCount() == SendErrorCount) + { + // Mark the LANA as offline + + m_handler.lanaStatusChange( getLana(), false); + + // Clear the error count + + clearErrorCount(); + + // Log the error + + if ( logger.isErrorEnabled()) + logger.error("Marked LANA as unavailable due to send errors"); + } + } + else + { + // Clear the error count + + clearErrorCount(); + } } } \ No newline at end of file diff --git a/source/java/org/alfresco/filesys/smb/mailslot/WinsockNetBIOSHostAnnouncer.java b/source/java/org/alfresco/filesys/smb/mailslot/WinsockNetBIOSHostAnnouncer.java index b51028aaa9..147a314911 100644 --- a/source/java/org/alfresco/filesys/smb/mailslot/WinsockNetBIOSHostAnnouncer.java +++ b/source/java/org/alfresco/filesys/smb/mailslot/WinsockNetBIOSHostAnnouncer.java @@ -16,6 +16,8 @@ */ package org.alfresco.filesys.smb.mailslot; +import java.io.IOException; + import org.alfresco.filesys.netbios.NetBIOSName; import org.alfresco.filesys.netbios.win32.NetBIOS; import org.alfresco.filesys.netbios.win32.NetBIOSSocket; @@ -34,6 +36,10 @@ import org.alfresco.filesys.smb.server.win32.Win32NetBIOSSessionSocketHandler; */ public class WinsockNetBIOSHostAnnouncer extends HostAnnouncer { + // Number of send errors before marking the LANA as offline + + private static final int SendErrorCount = 3; + // Associated session handler private Win32NetBIOSSessionSocketHandler m_handler; @@ -116,8 +122,49 @@ public class WinsockNetBIOSHostAnnouncer extends HostAnnouncer // Send the host announce datagram via the Win32 Netbios() API call - int sts = m_dgramSocket.sendDatagram(destNbName, buf, 0, len); - if ( sts != len) - logger.debug("WinsockNetBIOS host announce error"); + boolean txOK = false; + + try + { + int sts = m_dgramSocket.sendDatagram(destNbName, buf, 0, len); + if ( sts == len) + txOK = true; + } + catch ( IOException ex) + { + // Log the error + + if ( logger.isErrorEnabled()) + logger.error("Host announce error, " + ex.getMessage() + ", (LANA " + getLana() + ")"); + } + + // Check if the send was successful + + if ( txOK == false) + { + // Update the error count + + if ( incrementErrorCount() == SendErrorCount) + { + // Mark the LANA as offline + + m_handler.lanaStatusChange( getLana(), false); + + // Clear the error count + + clearErrorCount(); + + // Log the error + + if ( logger.isErrorEnabled()) + logger.error("Marked LANA as unavailable due to send errors, (LANA " + getLana() + ")"); + } + } + else + { + // Clear the error count + + clearErrorCount(); + } } } \ No newline at end of file diff --git a/source/java/org/alfresco/filesys/smb/server/FindInfoPacker.java b/source/java/org/alfresco/filesys/smb/server/FindInfoPacker.java index eb0045f03e..35febce405 100644 --- a/source/java/org/alfresco/filesys/smb/server/FindInfoPacker.java +++ b/source/java/org/alfresco/filesys/smb/server/FindInfoPacker.java @@ -40,24 +40,24 @@ class FindInfoPacker // File information levels - public static final int InfoStandard = 1; - public static final int InfoQueryEASize = 2; - public static final int InfoQueryEAFromList = 3; - public static final int InfoDirectory = 0x101; - public static final int InfoFullDirectory = 0x102; - public static final int InfoNames = 0x103; - public static final int InfoDirectoryBoth = 0x104; - public static final int InfoMacHfsInfo = 0x302; + public static final int InfoStandard = 1; + public static final int InfoQueryEASize = 2; + public static final int InfoQueryEAFromList = 3; + public static final int InfoDirectory = 0x101; + public static final int InfoFullDirectory = 0x102; + public static final int InfoNames = 0x103; + public static final int InfoDirectoryBoth = 0x104; + public static final int InfoMacHfsInfo = 0x302; // File information fixed lengths, includes nulls on strings. - public static final int InfoStandardLen = 24; - public static final int InfoQueryEASizeLen = 28; - public static final int InfoDirectoryLen = 64; - public static final int InfoFullDirectoryLen = 68; - public static final int InfoNamesLen = 12; - public static final int InfoDirectoryBothLen = 94; - public static final int InfoMacHfsLen = 120; + public static final int InfoStandardLen = 24; + public static final int InfoQueryEASizeLen = 28; + public static final int InfoDirectoryLen = 64; + public static final int InfoFullDirectoryLen = 68; + public static final int InfoNamesLen = 12; + public static final int InfoDirectoryBothLen = 94; + public static final int InfoMacHfsLen = 120; /** * Pack a file information object into the specified buffer, using information level 1 format. @@ -426,7 +426,7 @@ class FindInfoPacker // Align the buffer pointer and set the offset to the next file information entry - buf.longwordAlign(); + buf.wordAlign(); int curPos = buf.getPosition(); buf.setPosition(startPos); @@ -518,7 +518,7 @@ class FindInfoPacker // Align the buffer pointer and set the offset to the next file information entry - buf.longwordAlign(); + buf.wordAlign(); int curPos = buf.getPosition(); buf.setPosition(startPos); @@ -615,7 +615,7 @@ class FindInfoPacker // Align the buffer pointer and set the offset to the next file information entry - buf.longwordAlign(); + buf.wordAlign(); int curPos = buf.getPosition(); buf.setPosition(startPos); @@ -718,7 +718,7 @@ class FindInfoPacker // Align the buffer pointer and set the offset to the next file information entry - buf.longwordAlign(); + buf.wordAlign(); int curPos = buf.getPosition(); buf.setPosition(startPos); @@ -839,7 +839,7 @@ class FindInfoPacker // Align the buffer pointer and set the offset to the next file information entry - buf.longwordAlign(); + buf.wordAlign(); int curPos = buf.getPosition(); buf.setPosition(startPos); diff --git a/source/java/org/alfresco/filesys/smb/server/SMBServer.java b/source/java/org/alfresco/filesys/smb/server/SMBServer.java index 60644ee9a2..ce08072aec 100644 --- a/source/java/org/alfresco/filesys/smb/server/SMBServer.java +++ b/source/java/org/alfresco/filesys/smb/server/SMBServer.java @@ -78,7 +78,7 @@ public class SMBServer extends NetworkFileServer implements Runnable // Server type flags, used when announcing the host - private int m_srvType = ServerType.WorkStation + ServerType.Server; + private int m_srvType = ServerType.WorkStation + ServerType.Server + ServerType.NTServer; // Next available session id diff --git a/source/java/org/alfresco/filesys/smb/server/SMBSrvSession.java b/source/java/org/alfresco/filesys/smb/server/SMBSrvSession.java index fa924a6944..51ad5cf2b6 100644 --- a/source/java/org/alfresco/filesys/smb/server/SMBSrvSession.java +++ b/source/java/org/alfresco/filesys/smb/server/SMBSrvSession.java @@ -1344,7 +1344,7 @@ public class SMBSrvSession extends SrvSession implements Runnable // We are using case sensitive pathnames and long file names - setDefaultFlags(SMBSrvPacket.FLG_CASELESS); + setDefaultFlags(0); setDefaultFlags2(SMBSrvPacket.FLG2_LONGFILENAMES + SMBSrvPacket.FLG2_UNICODE); // Access the authenticator for this server and determine if the server is in share or diff --git a/source/java/org/alfresco/filesys/smb/server/repo/ContentDiskDriver.java b/source/java/org/alfresco/filesys/smb/server/repo/ContentDiskDriver.java index 954b82d55a..6f857b19a9 100644 --- a/source/java/org/alfresco/filesys/smb/server/repo/ContentDiskDriver.java +++ b/source/java/org/alfresco/filesys/smb/server/repo/ContentDiskDriver.java @@ -311,7 +311,8 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface // Set parameters - context.setFilesystemAttributes(FileSystem.CasePreservedNames); + context.setFilesystemAttributes(FileSystem.CasePreservedNames + FileSystem.UnicodeOnDisk + + FileSystem.CaseSensitiveSearch); } catch (Exception ex) { @@ -1468,15 +1469,6 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface " node: " + nodeRef); } } - catch (FileNotFoundException e) - { - // already gone - if (logger.isDebugEnabled()) - { - logger.debug("Deleted file : \n" + - " file: " + name); - } - } catch (NodeLockedException ex) { // Debug