Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The PostgreSQL server side receives the fork process after the connection

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Main- > PostmasterMain- > ServerLoop: for (;;) {. / / will block here and monitor for changes in file descriptors selres = select (nSockets, & rmask, NULL, NULL, & timeout); if (selres > 0) {for (I = 0; I)

< MAXLISTEN; i++){ //找一个有效的fd if (ListenSocket[i] == PGINVALID_SOCKET) break; if (FD_ISSET(ListenSocket[i], &rmask)){ port = ConnCreate(ListenSocket[i]);->

StreamConnection- > accept BackendStartup (port); / / fork process |-- pid = fork_process (); | if (pid = = 0) {/ / child | InitPostmasterChild () | | ClosePostmasterPorts (false); | BackendInitialize (port) | | | / / this function will not return | BackendRun (port);-> PostgresMain: | |-- for ( ) {| | if (send_ready_for_query) {| |... | | | ReadyForQuery (whereToSendOutput) | -> pq_flush ();-> internal_flush- > secure_write- > secure_raw_write- > send | | send_ready_for_query = false |} | | firstchar = ReadCommand (& input_message) | | switch (firstchar): {| | case 'Q':exec_simple_query (query_string) | | |. | |} | |--} | |} |... father |-- return STATUS_OK / / disable father socket StreamClose (port- > sock) | ConnFree (port);}}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report