Reviewed-by: Steven Dake <[email protected]>

On Thu, Mar 7, 2013 at 9:55 AM, Jan Friesse <[email protected]> wrote:

> With introduce of rb alignment (55600762), it's not enough to subtract
> one from number of free bytes, but also alignment must be taken to
> account. Easiest solution is to subtract 9 bytes.
>
> Signed-off-by: Jan Friesse <[email protected]>
> ---
>  exec/coroipcs.c |   12 ++++++++++--
>  1 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/exec/coroipcs.c b/exec/coroipcs.c
> index 1adb7ae..36d18a4 100644
> --- a/exec/coroipcs.c
> +++ b/exec/coroipcs.c
> @@ -1225,8 +1225,16 @@ static int shared_mem_dispatch_bytes_left (const
> struct conn_info *conn_info)
>         } else {
>                 bytes_left = n_read - n_write;
>         }
> -       if (bytes_left > 0) {
> -               bytes_left--;
> +
> +       /*
> +        * Pointers in ring buffer are 64-bit alignment (in memcpy_dwrap)
> +        * To ensure we will not overwrite previous data,
> +        * 9 bytes (64-bit + 1 byte) are subtracted from bytes_left
> +        */
> +       if (bytes_left < 9) {
> +               bytes_left = 0;
> +       } else {
> +               bytes_left = bytes_left - 9;
>         }
>
>         return (bytes_left);
> --
> 1.7.1
>
> _______________________________________________
> discuss mailing list
> [email protected]
> http://lists.corosync.org/mailman/listinfo/discuss
>
_______________________________________________
discuss mailing list
[email protected]
http://lists.corosync.org/mailman/listinfo/discuss

Reply via email to