ngx_connection_t结构体
生活随笔
收集整理的這篇文章主要介紹了
ngx_connection_t结构体
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
[cpp]?view plaincopy
//服務器的被動連接?? ?? struct?ngx_connection_s?{?? ????//連接未使用時候,data域充當連接鏈表中的next指針.?? ????//當連接被使用時候,data域的意義由模塊而定.?? ????void???????????????*data;?? ????//連接對應的讀事件?? ????ngx_event_t????????*read;?? ????//連接對應的寫事件?? ????ngx_event_t????????*write;?? ?? ????//套接字句柄?? ????ngx_socket_t????????fd;?? ?? ????//直接接收網絡字節流的方法?? ????ngx_recv_pt?????????recv;?? ????//直接放松網絡字節流的方法?? ????ngx_send_pt?????????send;?? ????//以ngx_chain鏈表為參數,接收網絡字節流的方法?? ????ngx_recv_chain_pt???recv_chain;?? ????//以ngx_chain鏈表為參數,發送網絡字節流的方法?? ????ngx_send_chain_pt???send_chain;?? ?? ????//這個鏈接對應的listening_t監聽對象.?? ????//此鏈接由ngx_listening_t監聽的事件建立?? ????ngx_listening_t????*listening;?? ?? ????//這個連接已經發送出去的字節數?? ????off_t???????????????sent;?? ?? ????//記錄日志?? ????ngx_log_t??????????*log;?? ?? ????//在accept一個新連接的時候,會創建一個內存池,而這個連接結束時候,會銷毀一個內存池.?? ????//這里所說的連接是成功建立的tcp連接.內存池的大小由pool_size決定?? ????//所有的ngx_connect_t結構體都是預分配的?? ????ngx_pool_t?????????*pool;?? ?? ????//連接客戶端的結構體?? ????struct?sockaddr????*sockaddr;?? ????//連接客戶端的結構體長度?? ????socklen_t???????????socklen;?? ????//連接客戶端的ip(字符串形式)?? ????ngx_str_t???????????addr_text;?? ?? #if?(NGX_SSL)?? ????ngx_ssl_connection_t??*ssl;?? #endif?? ?? ????//本機中監聽端口對應的socketaddr結構體?? ????//也就是listen監聽對象中的socketaddr成員?? ????struct?sockaddr????*local_sockaddr;?? ?? ????//用于接收和緩存客戶端發來的字符流?? ????ngx_buf_t??????????*buffer;?? ?? ????//該字段表示將該連接以雙向鏈表形式添加到cycle結構體中的?? ????//reusable_connections_queen雙向鏈表中,表示可以重用的連接.?? ????ngx_queue_t?????????queue;?? ?? ????//連接使用次數,每次建立一條來自客戶端的連接,?? ????//或者建立一條與后端服務器的連接,number+1?? ????ngx_atomic_uint_t???number;?? ?? ????//處理請求的次數?? ????ngx_uint_t??????????requests;?? ?? ????//?? ????unsigned????????????buffered:8;?? ?? ????//日志級別?? ????unsigned????????????log_error:3;?????/*?ngx_connection_log_error_e?*/?? ?? ????//不期待字符流結束?? ????unsigned????????????unexpected_eof:1;?? ????//連接超時?? ????unsigned????????????timedout:1;?? ????//連接處理過程中出現錯誤?? ????unsigned????????????error:1;?? ????//標識此鏈接已經銷毀,內存池,套接字等都不可用?? ????unsigned????????????destroyed:1;?? ?? ????//連接處于空閑狀態?? ????unsigned????????????idle:1;?? ????//連接可以重用?? ????unsigned????????????reusable:1;?? ????//連接關閉?? ????unsigned????????????close:1;?? ?? ????//正在將文件中的數據法網另一端?? ????unsigned????????????sendfile:1;?? ????//連接中發送緩沖區的數據高于低潮,才發送數據.?? ????//與ngx_handle_write_event方法中的lowat相對應?? ????unsigned????????????sndlowat:1;?? ????//使用tcp的nodely特性?? ????unsigned????????????tcp_nodelay:2;???/*?ngx_connection_tcp_nodelay_e?*/?? ????//使用tcp的nopush特性?? ????unsigned????????????tcp_nopush:2;????/*?ngx_connection_tcp_nopush_e?*/?? ?? #if?(NGX_HAVE_IOCP)?? ????unsigned????????????accept_context_updated:1;?? #endif?? ?? #if?(NGX_HAVE_AIO_SENDFILE)?? ????unsigned????????????aio_sendfile:1;?? ????ngx_buf_t??????????*busy_sendfile;?? #endif?? ?? #if?(NGX_THREADS)?? ????ngx_atomic_t????????lock;?? #endif?? }; ?
總結
以上是生活随笔為你收集整理的ngx_connection_t结构体的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nginx源码分析之网络初始化
- 下一篇: unsigned a:1;