code, cm_freelanceEnabled, (code ? "<none>" : rootCellName));
if (code != 0 && !cm_freelanceEnabled)
{
- *reasonP = "can't find root cell name in afsd.ini";
+ *reasonP = "can't find root cell name in CellServDB";
return -1;
}
else if (cm_freelanceEnabled)
void
GenerateMiniDump(PEXCEPTION_POINTERS ep)
{
+ if (IsDebuggerPresent())
+ return;
+
if (ep == NULL)
{
// Generate exception to get proper context in dump
#include <setjmp.h>
#include "afsd.h"
#include "afsd_init.h"
+#include "lanahelper.h"
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
afsi_log("--- end dump ---");
#ifdef DEBUG
- DebugBreak();
+ if (IsDebuggerPresent())
+ DebugBreak();
#endif
SetEvent(WaitToTerminate);
afsi_log("SERVICE_CONTROL_SHUTDOWN");
/* Write all dirty buffers back to server */
- buf_CleanAndReset();
+ if ( !lana_OnlyLoopback() )
+ buf_CleanAndReset();
/* Force trace if requested */
code = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
SetServiceStatus(StatusHandle, &ServiceStatus);
/* Write all dirty buffers back to server */
- buf_CleanAndReset();
+ if ( !lana_OnlyLoopback() )
+ buf_CleanAndReset();
/* Force trace if requested */
code = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
case PBT_APMQUERYSUSPEND:
afsi_log("SERVICE_CONTROL_APMQUERYSUSPEND");
/* Write all dirty buffers back to server */
- buf_CleanAndReset();
+ if ( !lana_OnlyLoopback() )
+ buf_CleanAndReset();
+ afsi_log("SERVICE_CONTROL_APMQUERYSUSPEND buf_CleanAndReset complete");
dwRet = NO_ERROR;
break;
case PBT_APMQUERYSTANDBY:
afsi_log("SERVICE_CONTROL_APMQUERYSTANDBY");
/* Write all dirty buffers back to server */
- buf_CleanAndReset();
+ if ( !lana_OnlyLoopback() )
+ buf_CleanAndReset();
+ afsi_log("SERVICE_CONTROL_APMQUERYSTANDBY buf_CleanAndReset complete");
dwRet = NO_ERROR;
break;
* a log page at any given instant.
*/
cm_InitReq(&req);
-#ifdef NO_BKG_RETRIES
req.flags |= CM_REQ_NORETRY;
-#endif
wasDirty |= buf_CleanAsync(bp, &req);
/* now advance to the next buffer; the allp chain never changes,
* at any given time, and also ensures that the log is forced sufficiently far,
* if this buffer contains logged data.
*
- * Returns one if the buffer was dirty.
+ * Returns non-zero if the buffer was dirty.
*/
long buf_CleanAsyncLocked(cm_buf_t *bp, cm_req_t *reqp)
{
/* write buffer to disk cache (synchronous for now) */
diskcache_Update(bp->dcp, bp->datap, cm_data.buf_blockSize, bp->dataVersion);
#endif /* DISKCACHE95 */
+
+ /* if we get here and retries are not permitted
+ * then we need to exit this loop regardless of
+ * whether or not we were able to clear the dirty bit
+ */
+ if (reqp->flags & CM_REQ_NORETRY)
+ break;
};
/* do logging after call to GetLastError, or else */
/* now no locks are held; clean buffer and go on */
cm_InitReq(&req);
+ req.flags |= CM_REQ_NORETRY;
+
buf_CleanAsync(bp, &req);
buf_CleanWait(NULL, bp);
return cp;
}
-cm_cell_t *cm_FindCellByID(long cellID)
+cm_cell_t *cm_FindCellByID(afs_int32 cellID)
{
cm_cell_t *cp;
/* a cell structure */
typedef struct cm_cell {
afs_uint32 magic;
- long cellID; /* cell ID */
+ afs_int32 cellID; /* cell ID */
struct cm_cell *nextp; /* locked by cm_cellLock */
char name[CELL_MAXNAMELEN]; /* cell name; never changes */
cm_serverRef_t *vlServersp; /* locked by cm_serverLock */
extern cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags);
-extern cm_cell_t *cm_FindCellByID(long cellID);
+extern cm_cell_t *cm_FindCellByID(afs_int32 cellID);
extern void cm_ChangeRankCellVLServer(cm_server_t *tsp);
struct rx_connection *callp; /* locked by mx */
struct cm_user *userp; /* locked by mx; a held reference */
osi_mutex_t mx; /* mutex for some of these fields */
- unsigned long refCount; /* locked by cm_connLock */
+ unsigned long refCount; /* locked by cm_connLock */
int ucgen; /* ucellp's generation number */
long flags; /* locked by mx */
int cryptlevel; /* encrytion status */
/* callback info */
struct cm_server *cbServerp; /* server granting callback */
- time_t cbExpires; /* time callback expires */
+ time_t cbExpires; /* time callback expires */
/* access cache */
long anyAccess; /* anonymous user's access */
return LANA_INVALID;
}
for (i = 0; i < lana_list.length; i++) {
- if (lana_IsLoopback(lana_list.lana[i])) {
+ if (lana_IsLoopback(lana_list.lana[i],TRUE)) {
// Found one, return it.
#ifndef NOLOGGING
afsi_log("lana_FindLoopback: Found LAN adapter %d",
return FALSE;
}
for (i = 0; i < lana_list.length; i++) {
- if (!lana_IsLoopback(lana_list.lana[i])) {
+ if (!lana_IsLoopback(lana_list.lana[i],FALSE)) {
// Found one non-Loopback adapter
return FALSE;
}
// Is the given lana a Windows Loopback Adapter?
// TODO: implement a better check for loopback
// TODO: also check for proper bindings (IPv4)
-extern "C" BOOL lana_IsLoopback(lana_number_t lana)
+// For VMWare we only check the first five octets since the last one may vary
+extern "C" BOOL lana_IsLoopback(lana_number_t lana, BOOL reset)
{
NCB ncb;
struct {
} astat;
unsigned char kWLA_MAC[6] = { 0x02, 0x00, 0x4c, 0x4f, 0x4f, 0x50 };
unsigned char kVista_WLA_MAC[6] = { 0x7F, 0x00, 0x00, 0x01, 0x4f, 0x50 };
+ unsigned char kVMWare_MAC[5] = { 0x00, 0x50, 0x56, 0xC0, 0x00 };
int status;
HKEY hkConfig;
LONG rv;
return TRUE;
}
- // Reset the adapter: in Win32, this is required for every process, and
- // acts as an init call, not as a real hardware reset.
- memset(&ncb, 0, sizeof(ncb));
- ncb.ncb_command = NCBRESET;
- ncb.ncb_callname[0] = 100;
- ncb.ncb_callname[2] = 100;
- ncb.ncb_lana_num = lana;
- status = Netbios(&ncb);
- if (status == 0)
- status = ncb.ncb_retcode;
- if (status != 0) {
+ if (reset) {
+ // Reset the adapter: in Win32, this is required for every process, and
+ // acts as an init call, not as a real hardware reset.
+ memset(&ncb, 0, sizeof(ncb));
+ ncb.ncb_command = NCBRESET;
+ ncb.ncb_callname[0] = 100;
+ ncb.ncb_callname[2] = 100;
+ ncb.ncb_lana_num = lana;
+ status = Netbios(&ncb);
+ if (status == 0)
+ status = ncb.ncb_retcode;
+ if (status != 0) {
#ifndef NOLOGGING
- afsi_log("NCBRESET failed: lana %u, status %ld", lana, status);
+ afsi_log("NCBRESET failed: lana %u, status %ld", lana, status);
#endif
- return FALSE;
+ return FALSE;
+ }
}
// Use the NCBASTAT command to get the adapter address.
return FALSE;
}
return (memcmp(astat.status.adapter_address, kWLA_MAC, 6) == 0 ||
- memcmp(astat.status.adapter_address, kVista_WLA_MAC, 6) == 0);
+ memcmp(astat.status.adapter_address, kVista_WLA_MAC, 6) == 0 ||
+ memcmp(astat.status.adapter_address, kVMWare_MAC, 5) == 0);
}
// Get the netbios named used/to-be-used by the AFS SMB server.
}
if(regNbName[0] &&
- (regLana >=0 && lana_IsLoopback((lana_number_t) regLana))) {
+ (regLana >=0 && lana_IsLoopback((lana_number_t) regLana,FALSE))) {
strncpy(nbName,regNbName,15);
nbName[16] = 0;
strupr(nbName);
BOOL lana_OnlyLoopback(void);
- BOOL lana_IsLoopback(lana_number_t lana);
+ BOOL lana_IsLoopback(lana_number_t lana, BOOL reset);
long lana_GetUncServerNameEx(char *buffer, lana_number_t * pLana, int * pIsGateway, int flags);
}
else if (infoLevel == SMB_QUERY_FILE_STANDARD_INFO) {
smb_fid_t *fidp = smb_FindFIDByScache(vcp, scp);
- if (fidp) {
- lock_ObtainMutex(&fidp->mx);
- delonclose = fidp->flags & SMB_FID_DELONCLOSE;
- lock_ReleaseMutex(&fidp->mx);
- smb_ReleaseFID(fidp);
- }
qpi.u.QPfileStandardInfo.allocationSize = scp->length;
qpi.u.QPfileStandardInfo.endOfFile = scp->length;
scp->fileType == CM_SCACHETYPE_MOUNTPOINT ||
scp->fileType == CM_SCACHETYPE_INVALID) ? 1 : 0);
qpi.u.QPfileStandardInfo.reserved = 0;
+
+ if (fidp) {
+ lock_ReleaseMutex(&scp->mx);
+ lock_ObtainMutex(&fidp->mx);
+ lock_ObtainMutex(&scp->mx);
+ delonclose = fidp->flags & SMB_FID_DELONCLOSE;
+ lock_ReleaseMutex(&fidp->mx);
+ smb_ReleaseFID(fidp);
+ }
}
else if (infoLevel == SMB_QUERY_FILE_EA_INFO) {
qpi.u.QPfileEaInfo.eaSize = 0;