$OpenBSD: patch-provider_libserver_ECSession_cpp,v 1.13 2014/07/03 06:14:40 robert Exp $
--- provider/libserver/ECSession.cpp.orig	Fri May 23 15:56:38 2014
+++ provider/libserver/ECSession.cpp	Wed Jul  2 17:28:25 2014
@@ -603,14 +603,22 @@ 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);
 		}
@@ -939,11 +947,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;
 	}
