Commit 6ce2ce71 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Now uses DebugLib.

  Fixed search handle haemorrhaging.
Detail:
  The directory lookup routines cached directory search handles to avoid
    hammering the server with repeated requests to open directories.
    Unfortunately, it was possible for these to be forgotten without
    being freed up leading to resource loss at the server end.  Eventually,
    the server gives up servicing you and reports errors.  This will only
    occur once a significant number of accesses have been performed (the
    number depends entirely on server configuration).  This leak is now
    fixed.
Admin:
  Tested against Cerium - debug reports that no handles are being leaked.

Version 2.07. Tagged as 'LanManFS-2_07'
parent 2aa6c255
...@@ -45,8 +45,7 @@ CD = dir ...@@ -45,8 +45,7 @@ CD = dir
CPFLAGS = ~cfr~v CPFLAGS = ~cfr~v
WFLAGS = ~c~v WFLAGS = ~c~v
# sbrodie 5/1/99: Define LANMANFS to enable use of NFS headers DFLAGS = -UTML -DCOMPAT_INET4 -DLONGNAMES
DFLAGS = -UTML -DCOMPAT_INET4 -DLANMANFS -DLONGNAMES
AFLAGS = -depend !Depend ${THROWBACK} -Stamp -quit AFLAGS = -depend !Depend ${THROWBACK} -Stamp -quit
CFLAGS = -depend !Depend ${THROWBACK} -c -Wpcs -ff -zps1 -zM ${INCLUDES},. ${DFLAGS} CFLAGS = -depend !Depend ${THROWBACK} -c -Wpcs -ff -zps1 -zM ${INCLUDES},. ${DFLAGS}
CMHGFLAGS = -depend !Depend ${THROWBACK} -p CMHGFLAGS = -depend !Depend ${THROWBACK} -p
...@@ -64,6 +63,7 @@ ABSSYM = RISC_OSLib:o.AbsSym ...@@ -64,6 +63,7 @@ ABSSYM = RISC_OSLib:o.AbsSym
INETLIB = TCPIPLibs:o.inetlibzm INETLIB = TCPIPLibs:o.inetlibzm
SOCKLIB = TCPIPLibs:o.socklibzm SOCKLIB = TCPIPLibs:o.socklibzm
UNIXLIB = TCPIPLibs:o.unixlibzm UNIXLIB = TCPIPLibs:o.unixlibzm
DEBUGLIB = C:DebugLib.o.DebugLibZM
...@@ -79,9 +79,14 @@ ROM_OBJS = or.LanMan or.Omni or.Logon or.CoreFn or.Printers or.NameCache \ ...@@ -79,9 +79,14 @@ ROM_OBJS = or.LanMan or.Omni or.Logon or.CoreFn or.Printers or.NameCache \
# od.Xlate od.buflib Interface.o RMInfo.o Errors.o o.Transact \ # od.Xlate od.buflib Interface.o RMInfo.o Errors.o o.Transact \
# od.LLC od.NetBIOS od.SMB od.Attr od.RPC od.NBIP od.Stats LanMan_MH.o # od.LLC od.NetBIOS od.SMB od.Attr od.RPC od.NBIP od.Stats LanMan_MH.o
DBG_OBJS = od.LanMan od.Omni od.Logon od.CoreFn od.Printers od.NameCache \ #DBG_OBJS = od.LanMan od.Omni od.Logon od.CoreFn od.Printers od.NameCache \
od.Xlate od.buflib Interface.o RMInfo.o Errors.o od.Transact \ # od.Xlate od.buflib Interface.o RMInfo.o Errors.o od.Transact \
o.LLC o.NetBIOS od.SMB o.Attr od.RPC od.NBIP od.Stats LanMan_MH.o # o.LLC o.NetBIOS od.SMB o.Attr od.RPC od.NBIP od.Stats LanMan_MH.o
DBG_OBJS = od.LanMan o.Omni o.Logon o.CoreFn o.Printers o.NameCache \
o.Xlate o.buflib Interface.o RMInfo.o Errors.o o.Transact \
o.LLC o.NetBIOS od.SMB o.Attr o.RPC o.NBIP o.Stats LanMan_MH.o
OBJSI = i.LanMan i.Omni i.Logon i.CoreFn i.Printers i.NameCache \ OBJSI = i.LanMan i.Omni i.Logon i.CoreFn i.Printers i.NameCache \
i.Xlate i.buflib i.Transact \ i.Xlate i.buflib i.Transact \
...@@ -101,7 +106,7 @@ LanMan_MH.h: LanMan_MH.o ...@@ -101,7 +106,7 @@ LanMan_MH.h: LanMan_MH.o
.SUFFIXES: .o .od .or .s .c .i .h .cmhg .inst .SUFFIXES: .o .od .or .s .c .i .h .cmhg .inst
.c.o:; ${CC} ${CFLAGS} -o $@ $< .c.o:; ${CC} ${CFLAGS} -o $@ $<
.c.or:; ${CC} ${CFLAGS} -DROM -o $@ $< .c.or:; ${CC} ${CFLAGS} -DROM -o $@ $<
.c.od:; ${CC} ${CFLAGS} -DDEBUG -DTRACE -Dprintf=module_printf -o $@ $< .c.od:; ${CC} ${CFLAGS} -DDEBUG -DDEBUGLIB -DTRACE -Dprintf=module_printf -o $@ $<
.c.i:; $(CC) $(CFLAGS) -c -C -E $< >> $@ .c.i:; $(CC) $(CFLAGS) -c -C -E $< >> $@
.i.inst:; $(CC) $(CFLAGS) -C++ -o $@ $< .i.inst:; $(CC) $(CFLAGS) -C++ -o $@ $<
.cmhg.o:; ${CMHG} ${CMHGFLAGS} -o $@ $< -d $*.h .cmhg.o:; ${CMHG} ${CMHGFLAGS} -o $@ $< -d $*.h
...@@ -169,7 +174,7 @@ ${RAM_MODULE}: ${OBJS} o.dirs ...@@ -169,7 +174,7 @@ ${RAM_MODULE}: ${OBJS} o.dirs
${DBG_MODULE}: ${DBG_OBJS} o.dirs ${DBG_MODULE}: ${DBG_OBJS} o.dirs
${MKDIR} rm ${MKDIR} rm
${LD} -o $@ -rmf ${DBG_OBJS} ${UNIXLIB} ${INETLIB} ${SOCKLIB} ${CLIB} ${LD} -o $@ -rmf ${DBG_OBJS} ${UNIXLIB} ${INETLIB} ${SOCKLIB} ${DEBUGLIB} ${CLIB}
${MODSQZ} $@ ${MODSQZ} $@
# #
......
/* (2.06) /* (2.07)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* *
*/ */
#define Module_MajorVersion_CMHG 2.06 #define Module_MajorVersion_CMHG 2.07
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 19 Apr 1999 #define Module_Date_CMHG 29 Apr 1999
#define Module_MajorVersion "2.06" #define Module_MajorVersion "2.07"
#define Module_Version 206 #define Module_Version 207
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "19 Apr 1999" #define Module_Date "29 Apr 1999"
#define Module_FullVersion "2.06" #define Module_FullVersion "2.07"
...@@ -946,32 +946,6 @@ static err_t ProcessCmdLine ( const char *_line ) ...@@ -946,32 +946,6 @@ static err_t ProcessCmdLine ( const char *_line )
/* ------------------------------- */ /* ------------------------------- */
#if 0
static void LM_StartupBoot ( void )
{
/* Checks to see if we need to boot (by reading the CMOS RAM).
If so, it
i) Gets the workgroup/domain name from CMOS RAM
ii) Tries to find a DC for the given name. If so, it uses this
as the server name.
iii) Attempts to mount "ARMBOOT", with user ARMBOOT and no password.
*/
if ( RdCMOS(CMOS_FSNUMBER) != Our_FS_Number )
return;
if ( (RdCMOS(CMOS_FSFLAGS) & FSF_BOOT) == 0 )
return;
#ifdef AUTOBOOT_ON_INIT
LM_Boot();
#endif
}
#endif
void LM_Boot(void) void LM_Boot(void)
{ {
int tries=1; int tries=1;
...@@ -1053,6 +1027,11 @@ _kernel_oserror *LM_Initialise(const char *cmd_tail, int pod_base, void *pw) ...@@ -1053,6 +1027,11 @@ _kernel_oserror *LM_Initialise(const char *cmd_tail, int pod_base, void *pw)
_kernel_oserror *err; _kernel_oserror *err;
_kernel_swi_regs R; _kernel_swi_regs R;
debug_initialise("LanManFS", "", "");
debug_atexit();
debug_set_options(0,0,0);
debug_output_device(DEBUGIT_OUTPUT);
LM_Vars.initialised = LMInitState_Uninitialised; LM_Vars.initialised = LMInitState_Uninitialised;
(void)pod_base; (void)pod_base;
......
...@@ -478,30 +478,36 @@ static BUFCHAIN MkDataString ( BUFCHAIN pB, int type, char *ptr ) ...@@ -478,30 +478,36 @@ static BUFCHAIN MkDataString ( BUFCHAIN pB, int type, char *ptr )
#ifdef DEBUG #ifdef DEBUG
static void DumpBuffer(void *ptr, int len) static void DumpBuffer(void *ptr, int len)
{ {
static char DumpBuf[256];
const char *membuf = ptr; const char *membuf = ptr;
char *db;
int i,j; int i,j;
db = DumpBuf;
*db = 0;
for (i=0; i<((len+31)&~31); ++i) { for (i=0; i<((len+31)&~31); ++i) {
if (!(i & 31)) { if (!(i & 31)) {
printf(" "); db += sprintf(db, " ");
if (i) for (j = i - 32; j != i; ++j) { if (i) for (j = i - 32; j != i; ++j) {
printf("%c", (membuf[j]>=32 && membuf[j] != 0x7f) ? db += sprintf(db, "%c", (membuf[j]>=32 && membuf[j] != 0x7f) ?
membuf[j] : '.'); membuf[j] : '.');
} }
printf("\n%04x: ", i); dprintf(("BufferDump", "%s\n", DumpBuf));
db = DumpBuf;
db += sprintf(db, "%04x: ", i);
} }
if (i>=len) { if (i>=len) {
printf(" "); db += sprintf(db, " ");
if ((i & 1)) printf(" "); if ((i & 1)) db += sprintf(db, " ");
} }
else { else {
printf("%02x", membuf[i]); db += sprintf(db, "%02x", membuf[i]);
if ((i & 1)) printf(" "); if ((i & 1)) db += sprintf(db, " ");
} }
} }
if (i) for (printf(" "), j = i - 32; j != i; ++j) printf("%c", if (i) for (db += sprintf(db, " "), j = i - 32; j != i; ++j) db += sprintf(db, "%c",
j>=len ? ' ' : (membuf[j]>=32 && membuf[j] != 0x7f) ? j>=len ? ' ' : (membuf[j]>=32 && membuf[j] != 0x7f) ?
membuf[j] : '.'); membuf[j] : '.');
printf("\n"); dprintf(("BufferDump", "%s\n", DumpBuf));
} }
#else #else
#define DumpBuffer(ptr, len) ((void)0) #define DumpBuffer(ptr, len) ((void)0)
...@@ -574,7 +580,7 @@ static void *DumpVar(void *ptr, const char *name, unsigned long sz) ...@@ -574,7 +580,7 @@ static void *DumpVar(void *ptr, const char *name, unsigned long sz)
for (s=0; s<sz; ++s) { for (s=0; s<sz; ++s) {
value |= ((unsigned long)(*bptr++) << (s<<3UL)); value |= ((unsigned long)(*bptr++) << (s<<3UL));
} }
printf("%6s %s: %#lx (%ld)\n", sizestr[sz], name, value, value); dprintf(("%6s %s: %#lx (%ld)\n", sizestr[sz], name, value, value));
return bptr; return bptr;
} }
...@@ -633,7 +639,7 @@ static err_t Do_SMBResponse(hSHARE hS, int cmd, BUFCHAIN *ppB_out ) ...@@ -633,7 +639,7 @@ static err_t Do_SMBResponse(hSHARE hS, int cmd, BUFCHAIN *ppB_out )
/* Extract received data */ /* Extract received data */
debug2("Do_SMB (cmd=0x%x) - NB_GetData returned %d bytes\n", cmd, ChainLen(pB_rx)); debug2("Do_SMB (cmd=0x%x) - NB_GetData returned %d bytes\n", cmd, ChainLen(pB_rx));
#ifdef DEBUG #ifdef DEBUG
if (cmd == SMBsesssetup) pB_rx = DumpChain(pB_rx); if (cmd == SMBwriteBraw) pB_rx = DumpChain(pB_rx);
#endif #endif
SMB_RxHdr.wct = 0; SMB_RxHdr.wct = 0;
...@@ -2153,9 +2159,14 @@ enum { ...@@ -2153,9 +2159,14 @@ enum {
fnext_CONTINUE = 8 fnext_CONTINUE = 8
}; };
#ifdef DEBUGLIB
static int SIDS=0;
#endif
static err_t SMB_AbandonFind2( hSHARE hS, WORD dir_handle ) static err_t SMB_AbandonFind2( hSHARE hS, WORD dir_handle )
{ {
debug1("Terminating search op (dir_handle = 0x%04x)\n", dir_handle); dprintf(("SID", "Terminating search op (dir_handle = 0x%04x) (%d open)\n",
dir_handle, --SIDS));
SMB_TxWords[0] = dir_handle; SMB_TxWords[0] = dir_handle;
return Do_SMB(hS, SMBfindclose2, 1, NULL, NULL); return Do_SMB(hS, SMBfindclose2, 1, NULL, NULL);
} }
...@@ -2181,7 +2192,10 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count, ...@@ -2181,7 +2192,10 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
*/ */
debug3("SMB_ReadDirEntriesX2 -> path (%p) NextSearchOK (%d) count (%d)\n", debug3("SMB_ReadDirEntriesX2 -> path (%p) NextSearchOK (%d) count (%d)\n",
path, con->t1.NextSearchOK, count); path, con->t1.NextSearchOK, count);
(void) SMB_AbandonFind2( hS, con->dir_handle ); if (con->dir_handle_valid) {
(void) SMB_AbandonFind2( hS, con->dir_handle );
con->dir_handle_valid = false;
}
} }
con->t1. NextSearchOK = false; con->t1. NextSearchOK = false;
...@@ -2194,6 +2208,10 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count, ...@@ -2194,6 +2208,10 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
/* Initial search - note we accept SIX return parameters - contrary to /* Initial search - note we accept SIX return parameters - contrary to
* Microsoft's own document - because it doesn't work if you only pass 5. Grr. * Microsoft's own document - because it doesn't work if you only pass 5. Grr.
*/ */
if (con->dir_handle_valid) {
SMB_AbandonFind2( hS, con->dir_handle);
con->dir_handle_valid = false;
}
con->resume_key = 0; con->resume_key = 0;
flags = first_flags; flags = first_flags;
Transact_init(&con->tp, 6 * 2); /* will accept 6 WORD return params */ Transact_init(&con->tp, 6 * 2); /* will accept 6 WORD return params */
...@@ -2214,7 +2232,8 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count, ...@@ -2214,7 +2232,8 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
return res; return res;
p = con->tp.parms_out_buf; p = con->tp.parms_out_buf;
con->dir_handle = Transact_getword(p); p += 2; con->dir_handle = Transact_getword(p); p += 2;
debug1("SID = 0x%04hx\n", con->dir_handle); con->dir_handle_valid = true;
dprintf(("SID", "SID = 0x%04hx (%d open)\n", con->dir_handle, ++SIDS));
} }
else { else {
/* continuation */ /* continuation */
...@@ -2279,6 +2298,7 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count, ...@@ -2279,6 +2298,7 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
debug0("Bugger. Looks like client ran out of space (or could be name xlate code)\n"); debug0("Bugger. Looks like client ran out of space (or could be name xlate code)\n");
if (eos) { if (eos) {
(void) SMB_AbandonFind2( hS, con->dir_handle ); (void) SMB_AbandonFind2( hS, con->dir_handle );
con->dir_handle_valid = false;
} }
else { else {
int j; int j;
......
...@@ -35,6 +35,7 @@ union Transact_SearchContext { ...@@ -35,6 +35,7 @@ union Transact_SearchContext {
struct TransactParms tp; struct TransactParms tp;
DWORD resume_key; DWORD resume_key;
WORD dir_handle; WORD dir_handle;
bool dir_handle_valid;
char last_filename[DOS_NAME_LEN]; char last_filename[DOS_NAME_LEN];
} t2; } t2;
}; };
......
...@@ -20,18 +20,12 @@ ...@@ -20,18 +20,12 @@
* *
*/ */
#ifdef DEBUG #include "DebugLib/DebugLib.h"
#define debug0(f) printf (f)
#define debug1(f,a) printf (f,a)
#define debug2(f,a,b) printf (f,a,b)
#define debug3(f,a,b,c) printf (f,a,b,c)
#else
#define debug0(f)
#define debug1(f,a)
#define debug2(f,a,b)
#define debug3(f,a,b,c)
#endif
#define debug0(f) dprintf((__FILE__, f))
#define debug1(f,a) dprintf((__FILE__, f,a))
#define debug2(f,a,b) dprintf((__FILE__, f,a,b))
#define debug3(f,a,b,c) dprintf((__FILE__, f,a,b,c))
/* For RISCOS */ /* For RISCOS */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment