]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
morgan-patch-20040227
authorJeffrey Altman <jaltman@mit.edu>
Fri, 27 Feb 2004 18:20:34 +0000 (18:20 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 27 Feb 2004 18:20:34 +0000 (18:20 +0000)
* Add error checking and logging for WaitForMultipleObject calls

* Place log file in directory pointed to by TEMP env variable if defined

* Use the platform defined value for MAXIMUM_WAIT_OBJECTS instead of
  the value 100.  (WinNT.h defines this as 64)

* Add a new registry value "AllSubmount" which can be set to DWORD 0x00
  to disable the automatic creation of the \\AFS\all submount.  This is
  for sites which wish to restrict access to the world.

src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/afsd_service.c
src/WINNT/afsd/cm_dnlc.c
src/WINNT/afsd/smb.c
src/WINNT/afsd/smb3.c

index e4949a83026c829bc9fe74c21e090380fa4fe293..0b21124343a55c512dba2b4886ea54da0ff3a74c 100644 (file)
@@ -101,8 +101,15 @@ afsi_start()
        int code;
 
        afsi_file = INVALID_HANDLE_VALUE;
-       code = GetWindowsDirectory(wd, sizeof(wd));
-       if (code == 0) return;
+    if (getenv("TEMP"))
+    {
+        strcpy(wd, getenv("TEMP"));
+    }
+    else
+    {
+        code = GetWindowsDirectory(wd, sizeof(wd));
+        if (code == 0) return;
+    }
        strcat(wd, "\\afsd_init.log");
        GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t));
        afsi_file = CreateFile(wd, GENERIC_WRITE, FILE_SHARE_READ, NULL,
@@ -120,7 +127,7 @@ static int afsi_log_useTimestamp = 1;
 void
 afsi_log(char *pattern, ...)
 {
-       char s[100], t[100], u[100];
+       char s[100], t[100], d[100], u[100];
        int zilch;
        va_list ap;
        va_start(ap, pattern);
@@ -128,7 +135,8 @@ afsi_log(char *pattern, ...)
        vsprintf(s, pattern, ap);
     if ( afsi_log_useTimestamp ) {
         GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t));
-        sprintf(u, "%s: %s\n", t, s);
+               GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, d, sizeof(d));
+               sprintf(u, "%s %s: %s\n", d, t, s);
         if (afsi_file != INVALID_HANDLE_VALUE)
             WriteFile(afsi_file, u, strlen(u), &zilch, NULL);
 #ifdef NOTSERVICE
@@ -214,7 +222,6 @@ int afsd_InitCM(char **reasonP)
        srand(ntohl(cm_HostAddr));
 
        /* Look up configuration parameters in Registry */
-
        code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName,
                                0, KEY_QUERY_VALUE, &parmKey);
        if (code != ERROR_SUCCESS) {
@@ -825,7 +832,7 @@ void afsd_printStack(HANDLE hThread, CONTEXT *c)
   
     offset = 0;
   
-    afsi_log("\n--# FV EIP----- RetAddr- FramePtr StackPtr Symbol\n" );
+    afsi_log("\n--# FV EIP----- RetAddr- FramePtr StackPtr Symbol" );
   
     for ( frameNum = 0; ; ++ frameNum )
     {
@@ -849,7 +856,7 @@ void afsd_printStack(HANDLE hThread, CONTEXT *c)
       
         if ( s.AddrPC.Offset == 0 )
         {
-            afsi_log("(-nosymbols- PC == 0)\n" );
+            afsi_log("(-nosymbols- PC == 0)" );
         }
         else
         { 
@@ -858,7 +865,7 @@ void afsd_printStack(HANDLE hThread, CONTEXT *c)
             {
                 if ( GetLastError() != ERROR_INVALID_ADDRESS )
                 {
-                    afsi_log("SymGetSymFromAddr(): errno = %lu\n", 
+                    afsi_log("SymGetSymFromAddr(): errno = %lu", 
                              GetLastError());
                 }
             }
@@ -870,7 +877,7 @@ void afsd_printStack(HANDLE hThread, CONTEXT *c)
 
                 if ( offset != 0 )
                 {
-                    afsi_log(" %+ld bytes\n", (long) offset);
+                    afsi_log(" %+ld bytes", (long) offset);
                 }
             }
 
@@ -878,16 +885,15 @@ void afsd_printStack(HANDLE hThread, CONTEXT *c)
             {
                 if (GetLastError() != ERROR_INVALID_ADDRESS)
                 {
-                    afsi_log("Error: SymGetLineFromAddr(): errno = %lu\n", 
+                    afsi_log("Error: SymGetLineFromAddr(): errno = %lu", 
                              GetLastError());
                 }
             }
             else
             {
-                afsi_log("    Line: %s(%lu) %+ld bytes\n", Line.FileName, 
+                afsi_log("    Line: %s(%lu) %+ld bytes", Line.FileName, 
                          Line.LineNumber, offset);
             }
-         
         }
       
         /* no return address means no deeper stackframe */
@@ -939,7 +945,7 @@ LONG __stdcall afsd_ExceptionFilter(EXCEPTION_POINTERS *ep)
           
     if (ep->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT)
     {
-        afsi_log("EXCEPTION_BREAKPOINT - continue execition ...\n");
+        afsi_log("\nEXCEPTION_BREAKPOINT - continue execition ...\n");
     
 #ifdef _DEBUG
         if (allocRequestBrk)
index c3013a979bf7a6c5ad13c9da6d9f3d7f75b3b590..6ee75a55d20c0b441e4644d629208ea0ac49496f 100644 (file)
@@ -48,6 +48,7 @@ unsigned int MainThreadId;
 jmp_buf notifier_jmp;
 
 extern int traceOnPanic;
+extern HANDLE afsi_file;
 
 /*
  * Notifier function for use by osi_panic
@@ -75,9 +76,16 @@ static void afsd_notifier(char *msgp, char *filep, long line)
 
        afsd_ForceTrace(TRUE);
 
-       if (traceOnPanic) {
-               _asm int 3h;
-       }
+    afsi_log("--- begin dump ---");
+    cm_DumpSCache(afsi_file, "a");
+#ifdef keisa
+    cm_dnlcDump(afsi_file, "a");
+#endif
+    cm_DumpBufHashTable(afsi_file, "a");
+    smb_DumpVCP(afsi_file, "a");                       
+    afsi_log("--- end   dump ---");
+    
+    DebugBreak();      
 
        SetEvent(WaitToTerminate);
 
index ec53fbb5d3894ca52818ef24803dbfc1336ae849..57f7b5251d299ee2d4f31c428d64184c88361f2c 100644 (file)
@@ -206,7 +206,7 @@ cm_dnlcLookup ( adp, sp)
     unsigned int key, skey;
     char* aname = sp->searchNamep;
     char *ts = aname;
-    struct nc * tnc;
+    struct nc * tnc, * tnc_begin;
     int safety, match;
   
     if (!cm_useDnlc)
@@ -224,7 +224,8 @@ cm_dnlcLookup ( adp, sp)
     lock_ObtainRead(&cm_dnlcLock);
     dnlcstats.lookups++;            /* Is a dnlcread lock sufficient? */
 
-    for ( tvc = (cm_scache_t *) 0, tnc = nameHash[skey], safety=0; 
+    tnc_begin = nameHash[skey];
+    for ( tvc = (cm_scache_t *) 0, tnc = tnc_begin, safety=0; 
        tnc; tnc = tnc->next, safety++ ) 
     {
        if (tnc->dirp == adp) 
@@ -259,10 +260,10 @@ cm_dnlcLookup ( adp, sp)
            }
        }
        if (tnc->next == nameHash[skey]) 
-       {                       /* end of list */
+    {                  /* end of list */
            break;
        }
-       else if (safety >NCSIZE) 
+       else if (tnc->next == tnc_begin || safety >NCSIZE) 
        {
            dnlcstats.cycles++;
            lock_ReleaseRead(&cm_dnlcLock);
index ecb2ab41e55b9aa7bbacfea87be49b1f02c401f5..dfac0000ed9a323c5f1fb31b70a5146b5eb2dd91 100644 (file)
@@ -60,6 +60,7 @@ long ongoingOps = 0;
 unsigned int sessionGen = 0;
 
 extern void afsi_log(char *pattern, ...);
+extern HANDLE afsi_file;
 
 osi_hyper_t hzero = {0, 0};
 osi_hyper_t hones = {0xFFFFFFFF, -1};
@@ -88,14 +89,14 @@ int numNCBs, numSessions;
 int smb_maxVCPerServer;
 int smb_maxMpxRequests;
 
-#define NCBmax 100
+#define NCBmax MAXIMUM_WAIT_OBJECTS
 EVENT_HANDLE NCBavails[NCBmax], NCBevents[NCBmax];
 EVENT_HANDLE **NCBreturns;
 DWORD NCBsessions[NCBmax];
 NCB *NCBs[NCBmax];
 struct smb_packet *bufs[NCBmax];
 
-#define Sessionmax 100
+#define Sessionmax MAXIMUM_WAIT_OBJECTS
 EVENT_HANDLE SessionEvents[Sessionmax];
 unsigned short LSNs[Sessionmax];
 int lanas[Sessionmax];
@@ -181,6 +182,8 @@ extern char cm_confDir[];
        *(sizep) = strlen(cm_HostName)
 #endif /* DJGPP */
 
+extern char AFSConfigKeyName[];
+
 /*
  * Demo expiration
  *
@@ -1011,8 +1014,8 @@ retry:
 void smb_ReleaseFID(smb_fid_t *fidp)
 {
        cm_scache_t *scp;
-        smb_vc_t *vcp;
-        smb_ioctl_t *ioctlp;
+    smb_vc_t *vcp;
+    smb_ioctl_t *ioctlp;
 
     if (!fidp)
         return NULL;
@@ -1020,7 +1023,7 @@ void smb_ReleaseFID(smb_fid_t *fidp)
        scp = NULL;
        lock_ObtainWrite(&smb_rctLock);
        osi_assert(fidp->refCount-- > 0);
-        if (fidp->refCount == 0 && (fidp->flags & SMB_FID_DELETE)) {
+    if (fidp->refCount == 0 && (fidp->flags & SMB_FID_DELETE)) {
                vcp = fidp->vcp;
                if (!(fidp->flags & SMB_FID_IOCTL))
                        scp = fidp->scp;
@@ -1028,16 +1031,16 @@ void smb_ReleaseFID(smb_fid_t *fidp)
                thrd_CloseHandle(fidp->raw_write_event);
 
                /* and see if there is ioctl stuff to free */
-                ioctlp = fidp->ioctlp;
-                if (ioctlp) {
+        ioctlp = fidp->ioctlp;
+        if (ioctlp) {
                        if (ioctlp->prefix) cm_FreeSpace(ioctlp->prefix);
                        if (ioctlp->inAllocp) free(ioctlp->inAllocp);
                        if (ioctlp->outAllocp) free(ioctlp->outAllocp);
                        free(ioctlp);
-                }
-
-                free(fidp);
         }
+
+        free(fidp);
+    }
        lock_ReleaseWrite(&smb_rctLock);
 
        /* now release the scache structure */
@@ -1152,19 +1155,47 @@ int smb_FindShare(smb_vc_t *vcp, smb_packet_t *inp, char *shareName,
        smb_user_t *uidp;
        char temp[1024];
        DWORD sizeTemp;
-        char sbmtpath[256];
-        char *p, *q;
+    char sbmtpath[256];
+    char *p, *q;
+       HKEY parmKey;
+       DWORD code;
+    DWORD allSubmount = 1;
 
        if (strcmp(shareName, "IPC$") == 0) {
                *pathNamep = NULL;
                return 0;
        }
 
-       if (_stricmp(shareName, "all") == 0) {
+    /* if allSubmounts == 0, only return the //mountRoot/all share 
+     * if in fact it has been been created in the subMounts table.  
+     * This is to allow sites that want to restrict access to the 
+     * world to do so.
+     */
+       code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName,
+                               0, KEY_QUERY_VALUE, &parmKey);
+       if (code == ERROR_SUCCESS) {
+        len = sizeof(allSubmount);
+        code = RegQueryValueEx(parmKey, "AllSubmount", NULL, NULL,
+                                (BYTE *) &allSubmount, &len);
+        if (code != ERROR_SUCCESS) {
+            allSubmount = 1;
+        }
+        RegCloseKey (parmKey);
+       }
+
+       if (allSubmount && _stricmp(shareName, "all") == 0) {
                *pathNamep = NULL;
                return 1;
        }
 
+    /* In case, the all share is disabled we need to still be able
+     * to handle ioctl requests 
+     */
+       if (_stricmp(shareName, "ioctl$") == 0) {
+               *pathNamep = "/.__ioctl__";
+               return 1;
+       }
+
 #ifndef DJGPP
         strcpy(sbmtpath, "afsdsbmt.ini");
 #else /* DJGPP */
@@ -5671,15 +5702,48 @@ resume:
  */
 void smb_ClientWaiter(void *parmp)
 {
-       DWORD code, idx;
+       DWORD code;
+    int   idx;
 
        while (1) {
                code = thrd_WaitForMultipleObjects_Event(numNCBs, NCBevents,
                                              FALSE, INFINITE);
                if (code == WAIT_OBJECT_0)
                        continue;
-               idx = code - WAIT_OBJECT_0;
 
+        /* error checking */
+        if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numNCBs))
+        {
+            int abandonIdx = code - WAIT_ABANDONED_0;
+            afsi_log("Error: smb_ClientWaiter event %d abandoned, errno %d\n", abandonIdx, GetLastError());
+        }
+
+        if (code == WAIT_IO_COMPLETION)
+        {
+            afsi_log("Error: smb_ClientWaiter WAIT_IO_COMPLETION\n");
+            continue;
+        }
+        
+        if (code == WAIT_TIMEOUT)
+        {
+            afsi_log("Error: smb_ClientWaiter WAIT_TIMEOUT, errno %d\n", GetLastError());
+        }
+
+        if (code == WAIT_FAILED)
+        {
+            afsi_log("Error: smb_ClientWaiter WAIT_FAILED, errno %d\n", GetLastError());
+        }
+
+            idx = code - WAIT_OBJECT_0;
+        /* check idx range! */
+        if (idx < 0 || idx > (sizeof(NCBevents) / sizeof(NCBevents[0])))
+        {
+            /* this is fatal - log as much as possible */
+            afsi_log("Fatal: NCBevents idx [ %d ] out of range.\n", idx);
+            osi_assert(0);
+        }
+        
                thrd_ResetEvent(NCBevents[idx]);
                thrd_SetEvent(NCBreturns[0][idx]);
        }
@@ -5692,7 +5756,8 @@ void smb_ClientWaiter(void *parmp)
  */
 void smb_ServerWaiter(void *parmp)
 {
-       DWORD code, idx_session, idx_NCB;
+       DWORD code;
+    int idx_session, idx_NCB;
        NCB *ncbp;
 #ifdef DJGPP
         dos_ptr dos_ncb;
@@ -5704,7 +5769,38 @@ void smb_ServerWaiter(void *parmp)
                                                    FALSE, INFINITE);
                if (code == WAIT_OBJECT_0)
                        continue;
-               idx_session = code - WAIT_OBJECT_0;
+
+        if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numSessions))
+        {
+            int abandonIdx = code - WAIT_ABANDONED_0;
+            afsi_log("Error: smb_ServerWaiter (SessionEvents) event %d abandoned, errno %d\n", abandonIdx, GetLastError());
+        }
+       
+        if (code == WAIT_IO_COMPLETION)
+        {
+            afsi_log("Error: smb_ServerWaiter (SessionEvents) WAIT_IO_COMPLETION\n");
+            continue;
+        }
+       
+        if (code == WAIT_TIMEOUT)
+        {
+            afsi_log("Error: smb_ServerWaiter (SessionEvents) WAIT_TIMEOUT, errno %d\n", GetLastError());
+        }
+       
+        if (code == WAIT_FAILED)
+        {
+            afsi_log("Error: smb_ServerWaiter (SessionEvents) WAIT_FAILED, errno %d\n", GetLastError());
+        }
+       
+        idx_session = code - WAIT_OBJECT_0;
+
+        /* check idx range! */
+        if (idx_session < 0 || idx_session > (sizeof(SessionEvents) / sizeof(SessionEvents[0])))
+        {
+            /* this is fatal - log as much as possible */
+            afsi_log("Fatal: session idx [ %d ] out of range.\n", idx_session);
+            osi_assert(0);
+        }
 
                /* Get an NCB */
 NCBretry:
@@ -5712,7 +5808,39 @@ NCBretry:
                                                    FALSE, INFINITE);
                if (code == WAIT_OBJECT_0)
                        goto NCBretry;
-               idx_NCB = code - WAIT_OBJECT_0;
+
+        /* error checking */
+        if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numNCBs))
+        {
+            int abandonIdx = code - WAIT_ABANDONED_0;
+            afsi_log("Error: smb_ClientWaiter (NCBavails) event %d abandoned, errno %d\n", abandonIdx, GetLastError());
+        }
+       
+        if (code == WAIT_IO_COMPLETION)
+        {
+            afsi_log("Error: smb_ClientWaiter (NCBavails) WAIT_IO_COMPLETION\n");
+            continue;
+        }
+       
+        if (code == WAIT_TIMEOUT)
+        {
+            afsi_log("Error: smb_ClientWaiter (NCBavails) WAIT_TIMEOUT, errno %d\n", GetLastError());
+        }
+       
+        if (code == WAIT_FAILED)
+        {
+            afsi_log("Error: smb_ClientWaiter (NCBavails) WAIT_FAILED, errno %d\n", GetLastError());
+        }
+               
+        idx_NCB = code - WAIT_OBJECT_0;
+
+        /* check idx range! */
+        if (idx_NCB < 0 || idx_NCB > (sizeof(NCBsessions) / sizeof(NCBsessions[0])))
+        {
+            /* this is fatal - log as much as possible */
+            afsi_log("Fatal: idx_NCB [ %d ] out of range.\n", idx_NCB);
+            osi_assert(0);
+        }
 
                /* Link them together */
                NCBsessions[idx_NCB] = idx_session;
@@ -5755,9 +5883,10 @@ void smb_Server(VOID *parmp)
        int myIdx = (int) parmp;
        NCB *ncbp;
        NCB *outncbp;
-        smb_packet_t *bufp;
+    smb_packet_t *bufp;
        smb_packet_t *outbufp;
-        DWORD code, rcode, idx_NCB, idx_session;
+    DWORD code, rcode;
+    int idx_NCB, idx_session;
        UCHAR rc;
        smb_vc_t *vcp;
        smb_t *smbp;
@@ -5788,7 +5917,39 @@ void smb_Server(VOID *parmp)
                if (code == WAIT_OBJECT_0) {
                        continue;
         }
-               idx_NCB = code - WAIT_OBJECT_0;
+
+        /* error checking */
+        if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numNCBs))
+        {
+            int abandonIdx = code - WAIT_ABANDONED_0;
+            afsi_log("Error: smb_Server ( NCBreturns[%d] ) event %d abandoned, errno %d\n", myIdx, abandonIdx, GetLastError());
+        }
+       
+        if (code == WAIT_IO_COMPLETION)
+        {
+            afsi_log("Error: smb_Server ( NCBreturns[%d] ) WAIT_IO_COMPLETION\n", myIdx);
+            continue;
+        }
+       
+        if (code == WAIT_TIMEOUT)
+        {
+            afsi_log("Error: smb_Server ( NCBreturns[%d] ) WAIT_TIMEOUT, errno %d\n", myIdx, GetLastError());
+        }
+       
+        if (code == WAIT_FAILED)
+        {
+            afsi_log("Error: smb_Server ( NCBreturns[%d] ) WAIT_FAILED, errno %d\n", myIdx, GetLastError());
+        }
+
+        idx_NCB = code - WAIT_OBJECT_0;
+        
+        /* check idx range! */
+        if (idx_NCB < 0 || idx_NCB > (sizeof(NCBs) / sizeof(NCBs[0])))
+        {
+            /* this is fatal - log as much as possible */
+            afsi_log("Fatal: idx_NCB [ %d ] out of range.\n", idx_NCB);
+            osi_assert(0);
+        }
 
                ncbp = NCBs[idx_NCB];
 #ifdef DJGPP
@@ -5812,6 +5973,10 @@ void smb_Server(VOID *parmp)
                        case NRC_SCLOSED:
                        case NRC_SNUMOUT:
                                /* Client closed session */
+                if (reportSessionStartups) 
+                {
+                    afsi_log("session [ %d ] closed", idx_session);
+                }
                                dead_sessions[idx_session] = TRUE;
                                vcp = smb_FindVC(ncbp->ncb_lsn, 0, lanas[idx_session]);
                                /* Should also release vcp.  Also, would do
@@ -5887,8 +6052,10 @@ void smb_Server(VOID *parmp)
                        default:
                                /* A weird error code.  Log it, sleep, and
                                 * continue. */
-                               if (vcp->errorCount++ > 3)
+                               if (vcp->errorCount++ > 3) {
+                    afsi_log("session [ %d ] closed, vcp->errorCount = %d", idx_session, vcp->errorCount);
                                        dead_sessions[idx_session] = TRUE;
+                }
                                else {
                                        thrd_Sleep(1000);
                                        thrd_SetEvent(SessionEvents[idx_session]);
@@ -6065,6 +6232,8 @@ void InitNCBslot(int idx)
        EVENT_HANDLE retHandle;
        int i;
 
+    osi_assert( idx < (sizeof(NCBs) / sizeof(NCBs[0])) );
+
        NCBs[idx] = GetNCB();
        NCBavails[idx] = thrd_CreateEvent(NULL, FALSE, TRUE, NULL);
 #ifndef DJGPP
@@ -6185,11 +6354,14 @@ void smb_Listener(void *parmp)
 
                /* Log session startup */
 #ifdef NOTSERVICE
-            fprintf(stderr, "New session(ncb_lsn,ncb_lana_num) %d,%d starting from host "
-                                "%s\n",
-                  ncbp->ncb_lsn,ncbp->ncb_lana_num, rname);
+        fprintf(stderr, "New session(ncb_lsn,ncb_lana_num) %d,%d starting from host "
+                               "%s\n",
+                ncbp->ncb_lsn,ncbp->ncb_lana_num, rname);
 #endif
-               if (reportSessionStartups) {
+        afsi_log("New session(ncb_lsn,ncb_lana_num) (%d,%d) starting from host %s, %d ongoing ops",
+                  ncbp->ncb_lsn,ncbp->ncb_lana_num, rname, ongoingOps);
+
+        if (reportSessionStartups) {
 #ifndef DJGPP
                        HANDLE h;
                        char *ptbuf[1];
@@ -6214,16 +6386,17 @@ void smb_Listener(void *parmp)
 #endif /* !DJGPP */
                }
 
-                /* now ncbp->ncb_lsn is the connection ID */
-                vcp = smb_FindVC(ncbp->ncb_lsn, SMB_FLAG_CREATE, ncbp->ncb_lana_num);
+        /* now ncbp->ncb_lsn is the connection ID */
+        vcp = smb_FindVC(ncbp->ncb_lsn, SMB_FLAG_CREATE, ncbp->ncb_lana_num);
                vcp->flags |= flags;
-                strcpy(vcp->rname, rname);
+        strcpy(vcp->rname, rname);
 
                /* Allocate slot in session arrays */
                /* Re-use dead session if possible, otherwise add one more */
         /* But don't look at session[0], it is reserved */
                for (i = 1; i < numSessions; i++) {
                        if (dead_sessions[i]) {
+                afsi_log("connecting to dead session [ %d ]", i);
                                dead_sessions[i] = FALSE;
                                break;
                        }
@@ -6253,6 +6426,7 @@ void smb_Listener(void *parmp)
                        /* Also add new session event */
                        SessionEvents[i] = thrd_CreateEvent(NULL, FALSE, TRUE, NULL);
                        numSessions++;
+            afsi_log("increasing numNCBs [ %d ] numSessions [ %d ]", numNCBs, numSessions);
                        thrd_SetEvent(SessionEvents[0]);
                } else {
                        thrd_SetEvent(SessionEvents[i]);
@@ -6431,7 +6605,7 @@ void smb_NetbiosInit()
 
         if (code == 0) code = ncbp->ncb_retcode;
         if (code == 0) {
-            afsi_log("Netbios NCBADDNAME succeeded on lana %d", lana);
+            afsi_log("Netbios NCBADDNAME succeeded on lana %d\n", lana);
 #ifdef DJGPP
             /* we only use one LANA with djgpp */
             lana_list.lana[0] = lana;
index 0a230d12d648d92a2add1b1ff078e2df3cd6fa06..4fb7f0413e16001b2d28f758d53df8aded4e491c 100644 (file)
@@ -312,29 +312,29 @@ smb_tran2Packet_t *smb_NewTran2Packet(smb_vc_t *vcp, smb_packet_t *inp,
        int totalParms, int totalData)
 {
        smb_tran2Packet_t *tp;
-        smb_t *smbp;
+    smb_t *smbp;
         
-        smbp = (smb_t *) inp->data;
+    smbp = (smb_t *) inp->data;
        tp = malloc(sizeof(*tp));
-        memset(tp, 0, sizeof(*tp));
-        tp->vcp = vcp;
-        smb_HoldVC(vcp);
-        tp->curData = tp->curParms = 0;
-        tp->totalData = totalData;
-        tp->totalParms = totalParms;
-        tp->tid = smbp->tid;
-        tp->mid = smbp->mid;
-        tp->uid = smbp->uid;
-        tp->pid = smbp->pid;
+    memset(tp, 0, sizeof(*tp));
+    tp->vcp = vcp;
+    smb_HoldVC(vcp);
+    tp->curData = tp->curParms = 0;
+    tp->totalData = totalData;
+    tp->totalParms = totalParms;
+    tp->tid = smbp->tid;
+    tp->mid = smbp->mid;
+    tp->uid = smbp->uid;
+    tp->pid = smbp->pid;
        tp->res[0] = smbp->res[0];
        osi_QAdd((osi_queue_t **)&smb_tran2AssemblyQueuep, &tp->q);
-        tp->opcode = smb_GetSMBParm(inp, 14);
+    tp->opcode = smb_GetSMBParm(inp, 14);
        if (totalParms != 0)
-               tp->parmsp = malloc(totalParms);
+        tp->parmsp = malloc(totalParms);
        if (totalData != 0)
-               tp->datap = malloc(totalData);
+        tp->datap = malloc(totalData);
        tp->flags |= SMB_TRAN2PFLAG_ALLOC;
-        return tp;
+    return tp;
 }
 
 smb_tran2Packet_t *smb_GetTran2ResponsePacket(smb_vc_t *vcp,
@@ -381,14 +381,14 @@ smb_tran2Packet_t *smb_GetTran2ResponsePacket(smb_vc_t *vcp,
 /* free a tran2 packet; must be called with smb_globalLock held */
 void smb_FreeTran2Packet(smb_tran2Packet_t *t2p)
 {
-        if (t2p->vcp) smb_ReleaseVC(t2p->vcp);
+    if (t2p->vcp) smb_ReleaseVC(t2p->vcp);
        if (t2p->flags & SMB_TRAN2PFLAG_ALLOC) {
                if (t2p->parmsp)
                        free(t2p->parmsp);
                if (t2p->datap)
                        free(t2p->datap);
        }
-        free(t2p);
+    free(t2p);
 }
 
 /* called with a VC, an input packet to respond to, and an error code.
@@ -4063,17 +4063,24 @@ long smb_ReceiveNTTranNotifyChange(smb_vc_t *vcp, smb_packet_t *inp,
 
        fidp = smb_FindFID(vcp, fid, 0);
                 
-       osi_Log4(afsd_logp, "Request for NotifyChange filter 0x%x fid %d wtree %d file %s",
-                filter, fid, watchtree, osi_LogSaveString(afsd_logp, fidp->NTopen_wholepathp));
+    if (fidp) {
+        osi_Log4(afsd_logp, "Request for NotifyChange filter 0x%x fid %d wtree %d file %s",
+                 filter, fid, watchtree, osi_LogSaveString(afsd_logp, fidp->NTopen_wholepathp));
 
-       scp = fidp->scp;
-       lock_ObtainMutex(&scp->mx);
-       if (watchtree)
-               scp->flags |= CM_SCACHEFLAG_WATCHEDSUBTREE;
-       else
-               scp->flags |= CM_SCACHEFLAG_WATCHED;
-       lock_ReleaseMutex(&scp->mx);
-       smb_ReleaseFID(fidp);
+        scp = fidp->scp;
+        lock_ObtainMutex(&scp->mx);
+        if (watchtree)
+            scp->flags |= CM_SCACHEFLAG_WATCHEDSUBTREE;
+        else
+            scp->flags |= CM_SCACHEFLAG_WATCHED;
+        lock_ReleaseMutex(&scp->mx);
+        smb_ReleaseFID(fidp);
+    }
+    else 
+    {
+        /* nothing - just a warning to main log file ... */
+        afsi_log("Warning: cannot find fidp vcp = 0x%X, fid = %d", vcp, fid);
+    }
 
        outp->flags |= SMB_PACKETFLAG_NOSEND;