$OpenBSD: patch-provider_libserver_ECSession_cpp,v 1.10 2013/01/27 13:06:20 robert Exp $
--- provider/libserver/ECSession.cpp.orig	Wed Jan 23 13:42:32 2013
+++ provider/libserver/ECSession.cpp	Sun Jan 27 12:59:53 2013
@@ -566,14 +566,23 @@ void ECSession::RemoveBusyState(pthread_t threadId)
 	i = m_mapBusyStates.find(threadId);
 
 	if(i != m_mapBusyStates.end()) {
+		// Since the specified thread is done now, record how much work it has done for us
+#if OPENBSD
+		struct tms end;
+
+		if(threadId) {
+			times(&end);
+
+			AddClocks((end.tms_utime / CLOCKS_PER_SEC) - timespec2dbl(i->second.threadstart), 0, GetTimeOfDay() - i->second.start);
+#else
 		clockid_t clock;
 		struct timespec end;
 
-		// Since the specified thread is done now, record how much work it has done for us
 		if(pthread_getcpuclockid(threadId, &clock) == 0) {
 			clock_gettime(clock, &end);
 			
 			AddClocks(timespec2dbl(end) - timespec2dbl(i->second.threadstart), 0, GetTimeOfDay() - i->second.start);
+#endif
 		} else {
 			ASSERT(FALSE);
 		}
@@ -867,11 +876,20 @@ ECRESULT ECAuthSession::ValidateUserSocket(int socket,
 	uid_t uid;
 	char strbuf[1024];	
 #ifdef SO_PEERCRED
+#ifndef __OpenBSD__
 	struct ucred cr;
+#else
+	struct sockpeercred cr;
+#endif
 	unsigned int cr_len;
 
+#ifndef __OpenBSD__
 	cr_len = sizeof(struct ucred);
 	if(getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) != 0 || cr_len != sizeof(struct ucred)) {
+#else
+	cr_len = sizeof(struct sockpeercred);
+	if(getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) != 0 || cr_len != sizeof(struct sockpeercred)) {
+#endif
 		er = ZARAFA_E_LOGON_FAILED;
 		goto exit;
 	}
