您好,登錄后才能下訂單哦!
main->PostmasterMain->ServerLoop: for(;;){ ... //會阻塞在這,監視文件描述符的變化 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進程 |-- pid = fork_process(); | if (pid == 0){//child | InitPostmasterChild(); | ClosePostmasterPorts(false); | BackendInitialize(port); | //該函數不會返回 | 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 //關閉father socket StreamClose(port->sock); ConnFree(port); } } } }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。