apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Stoddard" <b...@wstoddard.com>
Subject Re: [PATCH] Suppress locking in UNIX apr_file_read and apr_file_write unless APR_XTHREAD is set
Date Mon, 11 Mar 2002 14:23:28 GMT
Sounds reasonable. Make sure to update the documentation and at least take a shot at
changing all the other platforms. If you break something, it will get fixed. It is more
important to get the semantics the same everywhere...

Bill


> This involves an API semantics change, so I'm posting it
> for comments before committing...
>
> The idea here is to skip the mutex locking for buffered
> file reads and writes unless the file has been created with
> APR_XTHREAD.  This fixes a bit of bogusness in the httpd,
> where we do a huge number of mutex lock/unlock cycles when
> reading the config file--which is only accessed by a single
> thread.
>
> --Brian
>
>
> Index: file_io/unix/readwrite.c
> ===================================================================
> RCS file: /home/cvs/apr/file_io/unix/readwrite.c,v
> retrieving revision 1.75
> diff -u -r1.75 readwrite.c
> --- file_io/unix/readwrite.c    18 Feb 2002 06:08:53 -0000    1.75
> +++ file_io/unix/readwrite.c    10 Mar 2002 05:33:53 -0000
> @@ -118,7 +118,9 @@
>          apr_uint64_t size = *nbytes;
>
>  #if APR_HAS_THREADS
> -        apr_thread_mutex_lock(thefile->thlock);
> +        if (thefile->flags & APR_XTHREAD) {
> +            apr_thread_mutex_lock(thefile->thlock);
> +        }
>  #endif
>
>          if (thefile->direction == 1) {
> @@ -164,7 +166,9 @@
>              rv = 0;
>          }
>  #if APR_HAS_THREADS
> -        apr_thread_mutex_unlock(thefile->thlock);
> +        if (thefile->flags & APR_XTHREAD) {
> +            apr_thread_mutex_unlock(thefile->thlock);
> +        }
>  #endif
>          return rv;
>      }
> @@ -223,7 +227,9 @@
>          int size = *nbytes;
>
>  #if APR_HAS_THREADS
> -        apr_thread_mutex_lock(thefile->thlock);
> +        if (thefile->flags & APR_XTHREAD) {
> +            apr_thread_mutex_lock(thefile->thlock);
> +        }
>  #endif
>
>          if ( thefile->direction == 0 ) {
> @@ -251,7 +257,9 @@
>          }
>
>  #if APR_HAS_THREADS
> -        apr_thread_mutex_unlock(thefile->thlock);
> +        if (thefile->flags & APR_XTHREAD) {
> +            apr_thread_mutex_unlock(thefile->thlock);
> +        }
>  #endif
>          return rv;
>      }
>
>


Mime
View raw message