Thinko in processing of SHM message size info? - Mailing list pgsql-hackers

From Antonin Houska
Subject Thinko in processing of SHM message size info?
Date
Msg-id 14359.1438866268@localhost
Whole thread Raw
Responses Re: Thinko in processing of SHM message size info?
List pgsql-hackers
Can anyone please explain why the following patch shouldn't be applied?

diff --git a/src/backend/storage/ipc/shm_mq.c b/src/backend/storage/ipc/shm_mq.c
index 126cb07..4cd52ac 100644
--- a/src/backend/storage/ipc/shm_mq.c
+++ b/src/backend/storage/ipc/shm_mq.c
@@ -584,7 +584,7 @@ shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait)            if
(mqh->mqh_partial_bytes+ rb > sizeof(Size))                lengthbytes = sizeof(Size) - mqh->mqh_partial_bytes;
  else 
-                lengthbytes = rb - mqh->mqh_partial_bytes;
+                lengthbytes = rb;            memcpy(&mqh->mqh_buffer[mqh->mqh_partial_bytes], rawdata,
 lengthbytes);            mqh->mqh_partial_bytes += lengthbytes; 


I'm failing to understand why anything should be subtracted. Note that the
previous iteration must have called shm_mq_inc_bytes_read(), so "rb" should
not include anything of mqh->mqh_partial_bytes. Thanks.

--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Raising our compiler requirements for 9.6
Next
From: Uriy Zhuravlev
Date:
Subject: Re: Performance improvement for joins where outer side is unique