andr-sokolov commented on code in PR #1772:
URL: https://github.com/apache/cloudberry/pull/1772#discussion_r3322478033


##########
contrib/interconnect/udp/ic_udpifc.c:
##########
@@ -1814,6 +1842,42 @@ ic_reset_pthread_sigmasks(sigset_t *sigs)
        return;
 }
 
+Size
+InterconnectShmemSizeUDPIFC(void) {
+       return sizeof(ICStatisticsShmem);
+}
+
+void
+InterconnectShmemInitUDPIFC(void)
+{
+       bool found;
+       pICStatisticsShmem = ShmemInitStruct("global interconnect statistics",
+                                       sizeof(ICStatisticsShmem), &found);
+    if (pICStatisticsShmem == NULL)
+        ereport(FATAL,
+                       (errcode(ERRCODE_OUT_OF_MEMORY),
+                        errmsg("not enough shared memory for global 
interconnect statistics")));
+       else if (!found)
+       {
+               pICStatisticsShmem->totalRecvQueueSize = 0;
+               pICStatisticsShmem->recvQueueSizeCountingTime = 0;
+               pICStatisticsShmem->totalCapacity = 0;
+               pICStatisticsShmem->capacityCountingTime = 0;
+               pICStatisticsShmem->totalBuffers = 0;
+               pICStatisticsShmem->bufferCountingTime = 0;
+               pICStatisticsShmem->retransmits = 0;
+               pICStatisticsShmem->startupCachedPktNum = 0;
+               pICStatisticsShmem->mismatchNum = 0;
+               pICStatisticsShmem->crcErrors = 0;
+               pICStatisticsShmem->sndPktNum = 0;
+               pICStatisticsShmem->recvPktNum = 0;
+               pICStatisticsShmem->disorderedPktNum = 0;
+               pICStatisticsShmem->duplicatedPktNum = 0;
+               pICStatisticsShmem->recvAckNum = 0;
+               pICStatisticsShmem->statusQueryMsgNum = 0;

Review Comment:
   what about memset to be sure that all the fields are set to 0?



##########
contrib/interconnect/udp/ic_udpifc.c:
##########
@@ -1814,6 +1842,42 @@ ic_reset_pthread_sigmasks(sigset_t *sigs)
        return;
 }
 
+Size
+InterconnectShmemSizeUDPIFC(void) {
+       return sizeof(ICStatisticsShmem);
+}
+
+void
+InterconnectShmemInitUDPIFC(void)
+{
+       bool found;
+       pICStatisticsShmem = ShmemInitStruct("global interconnect statistics",
+                                       sizeof(ICStatisticsShmem), &found);
+    if (pICStatisticsShmem == NULL)
+        ereport(FATAL,
+                       (errcode(ERRCODE_OUT_OF_MEMORY),
+                        errmsg("not enough shared memory for global 
interconnect statistics")));
+       else if (!found)

Review Comment:
   I suggest to remove `else` because `ereport(FATAL` leads to exit from the 
function
   ```suggestion
   
        if (!found)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to