$OpenBSD: patch-provider_libserver_ZarafaCmd_cpp,v 1.26 2013/01/27 13:06:20 robert Exp $

OpenBSD does not have CLOCK_THREAD_CPUTIME_ID.

--- provider/libserver/ZarafaCmd.cpp.orig	Sun Jan 20 17:29:55 2013
+++ provider/libserver/ZarafaCmd.cpp	Sun Jan 20 17:34:41 2013
@@ -542,10 +542,10 @@ int ns__logon(struct soap *soap, char *user, char *pas
     ECLicenseClient *lpLicenseClient = NULL;
     unsigned int ulLicenseResponse;
     unsigned char *lpLicenseResponse = NULL;
-	struct timespec startTimes = {0}, endTimes = {0};
+	struct tms	startTimes, endTimes;
 	double          dblStart = GetTimeOfDay();
 
-	clock_gettime(CLOCK_THREAD_CPUTIME_ID, &startTimes);
+	times(&startTimes);
 
     LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020llu: S logon", sessionID);
 
@@ -642,9 +642,9 @@ exit:
 
 	lpsResponse->er = er;
 
-	clock_gettime(CLOCK_THREAD_CPUTIME_ID, &endTimes);
+	times(&endTimes);
 
-	LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020llu: E logon 0x%08x %f %f", sessionID, er, timespec2dbl(endTimes) - timespec2dbl(startTimes), GetTimeOfDay() - dblStart);
+	LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020llu: E logon 0x%08x %f %f", sessionID, er, (double)(endTimes.tms_utime - startTimes.tms_utime) / CLOCKS_PER_SEC, GetTimeOfDay() - dblStart);
 
 	return SOAP_OK;
 }
@@ -662,10 +662,10 @@ int ns__ssoLogon(struct soap *soap, ULONG64 ulSessionI
 	xsd__base64Binary *lpOutput = NULL;
 	char*			lpszEnabled = NULL;
 	ECLicenseClient*lpLicenseClient = NULL;
-	struct timespec startTimes = {0}, endTimes = {0};
+	struct tms	startTimes, endTimes;
 	double          dblStart = GetTimeOfDay();
 
-	clock_gettime(CLOCK_THREAD_CPUTIME_ID, &startTimes);
+	times(&startTimes);
 
     LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": S ssoLogon", ulSessionId);
 
@@ -813,9 +813,9 @@ exit:
 nosso:
 	lpsResponse->er = er;
 
-	clock_gettime(CLOCK_THREAD_CPUTIME_ID, &endTimes);
+	times(&endTimes);
 
-	LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": E ssoLogon 0x%08x %f %f", ulSessionId, er, timespec2dbl(endTimes) - timespec2dbl(startTimes), GetTimeOfDay() - dblStart);
+	LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": E ssoLogon 0x%08x %f %f", ulSessionId, er, (double)(endTimes.tms_utime - startTimes.tms_utime) / CLOCKS_PER_SEC, GetTimeOfDay() - dblStart);
 
 	return SOAP_OK;
 }
@@ -827,10 +827,10 @@ int ns__logoff(struct soap *soap, ULONG64 ulSessionId,
 {
 	ECRESULT	er = erSuccess;
 	ECSession 	*lpecSession = NULL;
-	struct timespec startTimes = {0}, endTimes = {0};
+	struct tms	startTimes, endTimes;
 	double          dblStart = GetTimeOfDay();
 
-	clock_gettime(CLOCK_THREAD_CPUTIME_ID, &startTimes);
+	times(&startTimes);
 
     LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": S logoff", ulSessionId);
 
@@ -852,20 +852,20 @@ int ns__logoff(struct soap *soap, ULONG64 ulSessionId,
 exit:
     *result = er;
 
-	clock_gettime(CLOCK_THREAD_CPUTIME_ID, &endTimes);
-	LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": E logoff 0x%08x %f %f", ulSessionId, 0, timespec2dbl(endTimes) - timespec2dbl(startTimes), GetTimeOfDay() - dblStart);
+	times(&endTimes);
+	LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": E logoff 0x%08x %f %f", ulSessionId, 0, (double)(endTimes.tms_utime - startTimes.tms_utime) / CLOCKS_PER_SEC, GetTimeOfDay() - dblStart);
 
     return SOAP_OK;
 }
 
 #define SOAP_ENTRY_FUNCTION_HEADER(resultvar, fname) \
     ECRESULT		er = erSuccess; \
-    struct timespec	startTimes = {0}, endTimes = {0};	\
+    struct tms		startTimes, endTimes; \
     double			dblStart = GetTimeOfDay(); \
     ECSession		*lpecSession = NULL; \
     unsigned int 	*lpResultVar = &resultvar; \
 	char            *szFname = #fname; \
-    clock_gettime(CLOCK_THREAD_CPUTIME_ID, &startTimes); \
+    times(&startTimes); \
 	LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": S %s", ulSessionId, szFname); \
 	er = g_lpSessionManager->ValidateSession(soap, ulSessionId, &lpecSession, true);\
 	const bool bSupportUnicode = (er == erSuccess ? (lpecSession->GetCapabilities() & ZARAFA_CAP_UNICODE) != 0 : false); \
@@ -879,9 +879,9 @@ exit:
 #define SOAP_ENTRY_FUNCTION_FOOTER \
 __soapentry_exit: \
     *lpResultVar = er; \
-    clock_gettime(CLOCK_THREAD_CPUTIME_ID, &endTimes); \
+    times(&endTimes); \
     if(lpecSession) { \
-		LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": E %s 0x%08x %f %f", ulSessionId, szFname, er, timespec2dbl(endTimes) - timespec2dbl(startTimes), GetTimeOfDay() - dblStart); \
+		LOG_SOAP_DEBUG(g_lpSessionManager->GetLogger(), "%020"PRIu64": E %s 0x%08x %f %f", ulSessionId, szFname, er, (double)(endTimes.tms_stime - startTimes.tms_stime) / CLOCKS_PER_SEC, GetTimeOfDay() - dblStart); \
 		lpecSession->UpdateBusyState(pthread_self(), SESSION_STATE_SENDING); \
         lpecSession->Unlock(); \
     } \
