[Fedora-directory-commits] winsync/passwordsync/passsync syncserv.cpp, 1.13, 1.14 syncserv.h, 1.7, 1.8
Nathan Kinder (nkinder)
fedora-directory-commits at redhat.com
Thu Mar 30 22:59:28 UTC 2006
Author: nkinder
Update of /cvs/dirsec/winsync/passwordsync/passsync
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32422/passwordsync/passsync
Modified Files:
syncserv.cpp syncserv.h
Log Message:
186657 - Implemented locking around passhook data file access
Index: syncserv.cpp
===================================================================
RCS file: /cvs/dirsec/winsync/passwordsync/passsync/syncserv.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- syncserv.cpp 22 Mar 2006 18:51:16 -0000 1.13
+++ syncserv.cpp 30 Mar 2006 22:59:26 -0000 1.14
@@ -76,6 +76,7 @@
unsigned long size;
passhookEventHandle = CreateEvent(NULL, FALSE, FALSE, PASSHAND_EVENT_NAME);
+ passhookMutexHandle = CreateMutex(NULL, FALSE, PASSHOOK_MUTEX_NAME);
mainLdapConnection = NULL;
results = NULL;
currentResult = NULL;
@@ -211,10 +212,14 @@
timeStamp(&outLog);
outLog << "Backing off for " << BackoffTime(GetMinBackoff()) << "ms" << endl;
}
- WaitForSingleObject(passhookEventHandle, BackoffTime(GetMinBackoff()));
+ waitRes = WaitForSingleObject(passhookEventHandle, BackoffTime(GetMinBackoff()));
if(logLevel > 0) {
timeStamp(&outLog);
- outLog << "Backoff time expired. Attempting sync" << endl;
+ if (waitRes == WAIT_TIMEOUT) {
+ outLog << "Backoff time expired. Attempting sync" << endl;
+ } else {
+ outLog << "Received passhook event. Attempting sync" << endl;
+ }
}
}
@@ -226,24 +231,38 @@
if(passInfoList.size() > 0)
{
- if(saveSet(&passInfoList, dataFilename) == 0)
+ // Get mutex for passhook.dat
+ WaitForSingleObject(passhookMutexHandle, INFINITE);
+
+ // Need to loadSet here so we don't overwrite entries that passhook recently added
+ if(loadSet(&passInfoList, dataFilename) == 0)
{
- if(logLevel > 0)
+ if(saveSet(&passInfoList, dataFilename) == 0)
+ {
+ if(logLevel > 0)
+ {
+ timeStamp(&outLog);
+ outLog << passInfoList.size() << " entries saved to data file" << endl;
+ }
+ }
+ else
{
timeStamp(&outLog);
- outLog << passInfoList.size() << " entries saved to data file" << endl;
+ outLog << "Failed to save entries to data file" << endl;
}
- }
- else
- {
+ } else {
timeStamp(&outLog);
- outLog << "Failed to save entries to data file" << endl;
+ outLog << "Failed to load entries from file" << endl;
}
+
+ // Release mutex for passhook.dat
+ ReleaseMutex(passhookMutexHandle);
}
exit:
clearSet(&passInfoList);
CloseHandle(passhookEventHandle);
+ CloseHandle(passhookMutexHandle);
}
// ****************************************************************
@@ -258,6 +277,9 @@
char* dn = NULL;
int tempSize = passInfoList.size();
+ // Get mutex for passhook.dat
+ WaitForSingleObject(passhookMutexHandle, INFINITE);
+
if(loadSet(&passInfoList, dataFilename) == 0)
{
if((passInfoList.size() - tempSize) > 0)
@@ -289,6 +311,9 @@
outLog << "Failed to load entries from file" << endl;
}
+ // Release mutex for passhook.dat
+ ReleaseMutex(passhookMutexHandle);
+
if(passInfoList.size() > 0)
{
if(logLevel > 0)
Index: syncserv.h
===================================================================
RCS file: /cvs/dirsec/winsync/passwordsync/passsync/syncserv.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- syncserv.h 19 Apr 2005 22:07:44 -0000 1.7
+++ syncserv.h 30 Mar 2006 22:59:26 -0000 1.8
@@ -82,6 +82,7 @@
PASS_INFO_LIST passInfoList;
HANDLE passhookEventHandle;
+ HANDLE passhookMutexHandle;
// LDAP variables
LDAP* mainLdapConnection;
@@ -104,7 +105,8 @@
unsigned long maxBackoffTime;
int logLevel;
bool isRunning;
+ DWORD waitRes;
fstream outLog;
};
-#endif
\ No newline at end of file
+#endif
More information about the Fedora-directory-commits
mailing list