diff mbox

[ovs-dev] Windows tests: Applications abort when using threading (ovs_rwlock_init)

Message ID 20161228222705.16212-1-aserdean@cloudbasesolutions.com
State Accepted
Headers show

Commit Message

Alin Serdean Dec. 28, 2016, 10:27 p.m. UTC
Commit number: 1a15f390afd66efd161db78b86600832214dfb3c
https://github.com/openvswitch/ovs/commit/1a15f390afd66efd161db78b86600832214dfb3c
switched from `NULL` to `attr`. According to POSIX documentation this is
correct, unfortunately on Windows the current implementation of pthreads does
not support a pre-initialized attribute. Please see a fork of the implementation
https://github.com/GerHobbelt/pthread-win32/blob/19fd5054b29af1b4e3b3278bfffbb6274c6c89f5/pthread_rwlock_init.c#L59-L63
This is the same implementation as the official version found under:
ftp://sourceware.org/pub/pthreads-win32/)

A short debug output from `vswitch` to confirm the above:

>k
 Index  Function
--------------------------------------------------------------------------------
*1      ovs-vswitchd.exe!ovs_rwlock_init(const ovs_rwlock * l_=0x000001721c7da250)
 2      ovs-vswitchd.exe!open_dpif_backer(const char * type=0x000001721c7d8d60, dpif_backer * * backerp=0x000001721c7d89c0)
 3      ovs-vswitchd.exe!construct(ofproto * ofproto_=0x000001721c7d87d0)
 4      ovs-vswitchd.exe!ofproto_create(const char * datapath_name=0x000001721c7d86e0, const char * datapath_type=0x000001721c7d8750, ofproto * * ofprotop=0x000001721c7d80b8)
 5      ovs-vswitchd.exe!bridge_reconfigure(const ovsrec_open_vswitch * ovs_cfg=0x000001721c7e05b0)
 6      ovs-vswitchd.exe!bridge_run()
 7      ovs-vswitchd.exe!main(int argc=6, char * * argv=0x000001721c729e10)
 8      [External Code]

>? error
22
https://github.com/openvswitch/ovs/blob/master/lib/ovs-thread.c#L243

This patch is critical because the majority (over 800) of the unit tests
are failing.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
---
 lib/ovs-thread.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
index 058c434..55c1990 100644
--- a/lib/ovs-thread.c
+++ b/lib/ovs-thread.c
@@ -240,7 +240,13 @@  ovs_rwlock_init(const struct ovs_rwlock *l_)
     xpthread_rwlockattr_setkind_np(
         &attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
 #endif
+#ifdef _WIN32
+    /* XXX: The version of pthreads until 2.9.1 and including do not support
+     * pthread_rwlock_init with an initialized attribute */
+    error = pthread_rwlock_init(&l->lock, NULL);
+#else
     error = pthread_rwlock_init(&l->lock, &attr);
+#endif
     if (OVS_UNLIKELY(error)) {
         ovs_abort(error, "pthread_rwlock_init failed");
     }