[haiku-commits] haiku: hrev52297 - src/libs/compat/freebsd11_network

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 28 Aug 2018 15:50:25 -0400 (EDT)

hrev52297 adds 2 changesets to branch 'master'
old head: 03e5dd5273ae9bcef15db099630c4c8cf8b7bbdc
new head: 5e7b3530c8197a5950c34035dc33f5eb141d925a
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=5e7b3530c819+%5E03e5dd5273ae

----------------------------------------------------------------------------

6aed80b4f7a1: freebsd11_network: Implement pause() using snooze() instead of 
cvars.
  
  This is much simpler than the prior condvar-based method and should be
  functionally equivalent. It seems tsleep() cause a NULL dereference,
  though (which will be fixed in the next commit), so this probably
  also fixes #14355.
  
  Change-Id: I36968de38ceb0a1c0896cae8839821f5ca383504
  Reviewed-on: https://review.haiku-os.org/489
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

5e7b3530c819: freebsd11_network: Tolerate a NULL mutex being passed to msleep.
  
  Our implementation of tsleep does this. It seems very few things
  actually use that, though, so the issue referenced in the previous
  commit may be one of the first things to use pause/tsleep.
  
  Change-Id: Id2edb2268b3b078b9ded5d634cfa241599f882f1
  Reviewed-on: https://review.haiku-os.org/490
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 17 insertions(+), 11 deletions(-)
src/libs/compat/freebsd11_network/synch.c | 19 ++++++++-----------
src/libs/compat/freebsd11_network/systm.c |  9 +++++++++

############################################################################

Commit:      6aed80b4f7a1e8e02ba97c13018402f014c69ff5
URL:         https://git.haiku-os.org/haiku/commit/?id=6aed80b4f7a1
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Tue Aug 28 19:38:11 2018 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Tue Aug 28 19:50:19 2018 UTC

Ticket:      https://dev.haiku-os.org/ticket/14355

freebsd11_network: Implement pause() using snooze() instead of cvars.

This is much simpler than the prior condvar-based method and should be
functionally equivalent. It seems tsleep() cause a NULL dereference,
though (which will be fixed in the next commit), so this probably
also fixes #14355.

Change-Id: I36968de38ceb0a1c0896cae8839821f5ca383504
Reviewed-on: https://review.haiku-os.org/489
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/libs/compat/freebsd11_network/synch.c 
b/src/libs/compat/freebsd11_network/synch.c
index 8f872636ba..d5eff17e82 100644
--- a/src/libs/compat/freebsd11_network/synch.c
+++ b/src/libs/compat/freebsd11_network/synch.c
@@ -36,12 +36,3 @@ wakeup(void* identifier)
 {
        publishedConditionNotifyAll(identifier);
 }
-
-
-int
-_pause(const char* waitMessage, int timeout)
-{
-       int waitChannel;
-       KASSERT(timeout != 0, ("pause: timeout required"));
-       return tsleep(&waitChannel, 0, waitMessage, timeout);
-}
diff --git a/src/libs/compat/freebsd11_network/systm.c 
b/src/libs/compat/freebsd11_network/systm.c
index f1c9df31fb..84d90740be 100644
--- a/src/libs/compat/freebsd11_network/systm.c
+++ b/src/libs/compat/freebsd11_network/systm.c
@@ -5,6 +5,15 @@
 
 
 #include <compat/sys/systm.h>
+#include <compat/sys/kernel.h>
+
+
+int
+_pause(const char* waitMessage, int timeout)
+{
+       KASSERT(timeout != 0, ("pause: timeout required"));
+       return snooze(ticks_to_usecs(timeout));
+}
 
 
 void

############################################################################

Revision:    hrev52297
Commit:      5e7b3530c8197a5950c34035dc33f5eb141d925a
URL:         https://git.haiku-os.org/haiku/commit/?id=5e7b3530c819
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Tue Aug 28 19:48:27 2018 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Tue Aug 28 19:50:19 2018 UTC

freebsd11_network: Tolerate a NULL mutex being passed to msleep.

Our implementation of tsleep does this. It seems very few things
actually use that, though, so the issue referenced in the previous
commit may be one of the first things to use pause/tsleep.

Change-Id: Id2edb2268b3b078b9ded5d634cfa241599f882f1
Reviewed-on: https://review.haiku-os.org/490
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/libs/compat/freebsd11_network/synch.c 
b/src/libs/compat/freebsd11_network/synch.c
index d5eff17e82..48a022340d 100644
--- a/src/libs/compat/freebsd11_network/synch.c
+++ b/src/libs/compat/freebsd11_network/synch.c
@@ -21,9 +21,15 @@ msleep(void* identifier, struct mtx* mutex, int priority,
 
        conditionPublish(&sleep, identifier, description);
 
-       mtx_unlock(mutex);
+       // FreeBSD's msleep() does not allow the mutex to be NULL, but we
+       // do, as we implement some other functions like tsleep() with it.
+       if (mutex != NULL)
+               mtx_unlock(mutex);
+
        status = publishedConditionTimedWait(identifier, timeout);
-       mtx_lock(mutex);
+
+       if (mutex != NULL)
+               mtx_lock(mutex);
 
        conditionUnpublish(&sleep);
 


Other related posts:

  • » [haiku-commits] haiku: hrev52297 - src/libs/compat/freebsd11_network - waddlesplash