In the file src/tspi/ps/tspps.c the function flock() is used if the SOLARIS 
define is not set.
This patch changes src/tcs/ps/tcsps.c in order to have the same behaviour of 
the mentioned file.


Signed-off-by: Roberto Sassu <[email protected]>
---
 src/tcs/ps/tcsps.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/tcs/ps/tcsps.c b/src/tcs/ps/tcsps.c
index 00ad435..a195252 100644
--- a/src/tcs/ps/tcsps.c
+++ b/src/tcs/ps/tcsps.c
@@ -46,7 +46,9 @@
 int system_ps_fd = -1;
 MUTEX_DECLARE(disk_cache_lock);
 
+#if defined (SOLARIS)
 static struct flock fl;
+#endif
 
 int
 get_file()
@@ -56,8 +58,12 @@ get_file()
        if (system_ps_fd != -1) {
                int rc = 0;
 
+#if defined (SOLARIS)
                fl.l_type = F_WRLCK;
                if ((rc = fcntl(system_ps_fd, F_SETLKW, &fl))) {
+#else
+               if ((rc = flock(system_ps_fd, LOCK_EX))) {
+#endif /* SOLARIS */
                        LogError("failed to get system PS lock: %s", 
strerror(errno));
                        return -1;
                }
@@ -73,8 +79,12 @@ get_file()
                return -1;
        }
 
+#if defined (SOLARIS)
        fl.l_type = F_WRLCK;
        if ((rc = fcntl(system_ps_fd, F_SETLKW, &fl))) {
+#else
+       if ((rc = flock(system_ps_fd, LOCK_EX))) {
+#endif /* SOLARIS */
                LogError("failed to get system PS lock of file %s: %s",
                        tcsd_options.system_ps_file, strerror(errno));
                return -1;
@@ -89,8 +99,12 @@ put_file(int fd)
        int rc = 0;
        /* release the file lock */
        
+#if defined (SOLARIS)
        fl.l_type = F_UNLCK;
        if ((rc = fcntl(fd, F_SETLKW, &fl))) {
+#else
+       if ((rc = flock(fd, LOCK_UN))) {
+#endif /* SOLARIS */
                LogError("failed to unlock system PS file: %s",
                        strerror(errno));
                return -1;
-- 
1.7.2.2


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech

Reply via email to