git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: svn commit: r1831871 - /httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c



On 05/18/2018 07:05 PM, ylavic@xxxxxxxxxx wrote:
> Author: ylavic
> Date: Fri May 18 17:05:18 2018
> New Revision: 1831871
> 
> URL: http://svn.apache.org/viewvc?rev=1831871&view=rev
> Log:
> mod_slotmem_shm: follow up to r1831869 (check persistent files).
> 
> Since persistent files are also reused on stop/start, we must ensure that
> they match the same descriptor when reused on the next startup, so add it
> to integrity metadata.
> 
> Also, the descriptor being the first field in the SHM, we don't need to
> copy on the stack it in several places, and can handle it as a pointer.
> 
> 
> Modified:
>     httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c
> 
> Modified: httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c?rev=1831871&r1=1831870&r2=1831871&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c (original)
> +++ httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c Fri May 18 17:05:18 2018

> @@ -200,37 +212,66 @@ static apr_status_t restore_slotmem(void
>          rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT,
>                             pool);
>          if (rv == APR_SUCCESS) {
> -            rv = apr_file_read(fp, ptr, &nbytes);
> -            if ((rv == APR_SUCCESS || rv == APR_EOF) && nbytes == size) {
> +            rv = apr_file_read_full(fp, ptr, dsize, NULL);
> +            if (rv == APR_SUCCESS || rv == APR_EOF) {
>                  rv = APR_SUCCESS;   /* for successful return @ EOF */
>                  /*
>                   * if at EOF, don't bother checking md5
>                   *  - backwards compatibility
>                   *  */
>                  if (apr_file_eof(fp) != APR_EOF) {
> -                    apr_size_t ds = APR_MD5_DIGESTSIZE;
> -                    rv = apr_file_read(fp, digest, &ds);
> -                    if ((rv == APR_SUCCESS || rv == APR_EOF) &&
> -                        ds == APR_MD5_DIGESTSIZE) {
> -                        rv = APR_SUCCESS;
> -                        apr_md5(digest2, ptr, nbytes);
> +                    rv = apr_file_read_full(fp, digest, APR_MD5_DIGESTSIZE, NULL);
> +                    if (rv == APR_SUCCESS || rv == APR_EOF) {

.....

> +                    else if (rv == APR_SUCCESS || rv == APR_EOF) {
> +                        rv = APR_INCOMPLETE;

Hm, how can the condition in else if ever be true? We only get to else if rv is neither APR_SUCCESS or APR_EOF.

Regards

Rüdiger