磨砺技术珠矶,践行数据之道,追求卓越价值  

回到上一级页面:PostgreSQL索引页

[作者:高健@博客园 luckyjackgao@gmail.com]

 

为了对 postmaster.c 中的 ListenSocket 进行研究,先将其代码做一个概括(大部分代码省略):

/*                                            
 * Postmaster main entry point                                            
 */                                            
int                                            
PostmasterMain(int argc, char *argv[])                                            
{                                            
    ……                                     
    status = ServerLoop();                 
    /*                                        
     * ServerLoop probably shouldn't ever return, but if it does, close down. 
     */                                        
    ExitPostmaster(status != STATUS_OK);   
    return 0;  /* not reached */                    
}

然后添加我自己的代码后变成如下样子:

/*                                            
 * Postmaster main entry point                                            
 */                                            
int                                            
PostmasterMain(int argc, char *argv[])                                            
{                                            
    ……                        
        /*added by gaojian begin*/
        for (i = 0; i < MAXLISTEN; i++)                            
        {                            
          if (ListenSocket[i] != PGINVALID_SOCKET){                        
            frpintf(stderr, "ListenSocket[%d] is: %d. \n", i,ListenSocket[i]); 
          }else{  break;  }    
        }            
        /*added by gaojian end*/                
                                            
    status = ServerLoop();                 
    /*                                        
     * ServerLoop probably shouldn't ever return, but if it does, close down.
     */                                        
    ExitPostmaster(status != STATUS_OK);                                        
                                            
    return 0;  /* not reached */                    
}    

启动后运行的结果是显示两行信息:
ListenSocket[0] is 3.
ListenSocket[1] is 4.

至于为何是两行结果,这两行结果在 ServerLoop()中又如何起作用,还有待进一步研究。

 

[作者:高健@博客园 luckyjackgao@gmail.com]

回到上一级页面:PostgreSQL索引页

磨砺技术珠矶,践行数据之道,追求卓越价值  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2021-11-26
猜你喜欢
  • 2021-05-29
  • 2021-06-13
  • 2021-11-22
  • 2022-01-13
  • 2021-07-11
  • 2021-11-03
  • 2021-05-28
相关资源
相似解决方案