opengauss项目代码注释 #26

Open
nuoya wants to merge 55 commits from nuoya/openGauss-server:master into master
1 changed files with 30 additions and 12 deletions
Showing only changes of commit 491e17288c - Show all commits

View File

@ -32,11 +32,17 @@
StreamCOMM::StreamCOMM(libcommaddrinfo* addr, bool flag) : m_addr(addr)
{
/* 初始化节点名称为空字符串 */
m_nodeName[0] = '\0';
/* 初始化节点OID为无效OID */
m_nodeoid = InvalidOid;
/* 设置通信类型为STREAM_COMM */
m_type = STREAM_COMM;
/* 设置发送方标志 */
m_sendSide = flag;
/* 初始化端口为NULL */
m_port = NULL;
/* 初始化缓冲区为NULL */
m_buffer = NULL;
}
@ -99,13 +105,20 @@ void StreamCOMM::init(char* dbname, char* usrname)
*/
void StreamCOMM::allocNetBuffer()
{
/* 分配端口结构内存并初始化为零 */
m_port = (Port*)palloc0(sizeof(Port));
/* 如果是发送方 */
if (m_sendSide) {
/* 分配StreamBuffer结构内存并初始化为零 */
m_buffer = (StreamBuffer*)palloc0(sizeof(StreamBuffer));
/* 设置发送缓冲区大小为STREAM_BUFFER_SIZE */
m_buffer->PqSendBufferSize = STREAM_BUFFER_SIZE;
/* 设置发送指针为0 */
m_buffer->PqSendPointer = 0;
/* 设置发送开始位置为0 */
m_buffer->PqSendStart = 0;
/* 设置通信忙标志为false */
m_buffer->PqCommBusy = false;
}
}
@ -118,17 +131,17 @@ void StreamCOMM::allocNetBuffer()
bool StreamCOMM::setActive()
{
/*
* if we use parallel send mode,
* and the head of address info list is already close,
* we must continue to send,
* and gs_broadcast can send to other node in address info list.
* 使
*
*
* gs_broadcast可以发送到地址信息列表中的其他节点
*/
if (m_addr->parallel_send_mode == true) {
/*
* if we use parallel send mode,
* we only send to head node of address info list,
* and do not care other node in address info list,
* gs_broadcast can parallel send to other node.
* 使
*
*
* gs_broadcast可以并行发送到其他节点
*/
if (m_addr->addr_list_size == 0)
return false;
@ -136,8 +149,10 @@ bool StreamCOMM::setActive()
return false;
}
/* 设置当前线程的ProcPort */
u_sess->proc_cxt.MyProcPort = m_port;
/* 设置发送缓冲区指针、大小和起始位置以及通信忙标志 */
t_thrd.libpq_cxt.PqSendBuffer = &m_buffer->PqSendBuffer[0];
t_thrd.libpq_cxt.PqSendPointer = m_buffer->PqSendPointer;
t_thrd.libpq_cxt.PqSendBufferSize = m_buffer->PqSendBufferSize;
@ -177,11 +192,14 @@ void StreamCOMM::setInActive()
*/
void StreamCOMM::updateInfo(StreamConnInfo* connInfo)
{
/* 获取节点名称的长度 */
int nodeNameLen = strlen(connInfo->nodeName);
errno_t rc = EOK;
/* 将连接信息中的套接字信息复制到StreamCOMM对象的套接字信息中 */
m_addr->gs_sock = connInfo->port.libcomm_layer.gsock;
rc = strncpy_s(m_nodeName, NAMEDATALEN, connInfo->nodeName, nodeNameLen + 1);
/* 将连接信息中的节点名称复制到StreamCOMM对象的节点名称中 */
errno_t rc = strncpy_s(m_nodeName, NAMEDATALEN, connInfo->nodeName, nodeNameLen + 1);
/* 检查字符串复制是否成功 */
securec_check(rc, "\0", "\0");
/* 将连接信息中的生产者SMP ID复制到StreamCOMM对象的streamKey中 */
m_addr->streamKey.producerSmpId = connInfo->producerSmpId;
}
}