Hi Roberto,

Actually, I while ago I decided to make fcntl the one used in TrouSerS at all, 
to avoid another set of ifdefs to support a so slight change. There's indeed a 
bug however, but instead I need to remove the flock support from 
src/tspi/ps/tspps.c.

Thanks for pointing this out
---
Rajiv Andrade
Security Development
IBM Linux Technology Center



On Sep 7, 2010, at 3:05 PM, Roberto Sassu wrote:

> 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


------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful, 
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance. 
http://p.sf.net/sfu/dell-sfdev2dev
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech

Reply via email to