Nginx 이벤트 처리 중의 connection 과 read, write 이벤트 의 연결
/*********************************************************************
* Author : Samson
* Date : 07/08/2015
* Test platform:
* gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
* GNU bash, 4.3.11(1)-release (x86_64-pc-linux-gnu)
* Nginx version:
* Nginx 1.6.2
* Nginx 1.8.0
* *******************************************************************/
Nginx 이벤트 처리 중의 connection 과 read, write 이벤트 의 연결:
Nginx 코드 에서 rev = c - > read 를 자주 볼 수 있 습 니 다.ngx_handle_read_event(rev, 0);이런 조작, 그렇다면 rev 는 무엇 일 까?
재 ngxepoll_add_이벤트 중의 ngxconnection_t *c = ev->data;중의 ev - > data 는 또 어떤 내용 입 니까?
사실 이 모든 것 은 ngxevent_process_init 에서 흔적 을 찾 았 습 니 다. 이 함수 에서 cycle 전역 구조의 read 를 진행 하 였 습 니 다.events、write_이벤트, connections 의 공간의 생 성 및 이 세 가지 관계.
이 세 구조의 생 성 코드:
cycle->connections = ngx_alloc(sizeof(ngx_connection_t) * cycle->connection_n, cycle->log);
cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n, cycle->log);
cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n, cycle->log);
//read_events、write_이벤트, connections 의 관련, 이 세 가 지 는 cycle 의 아래 표 시 는 연 결 된 이벤트 와 연결 에 대응 하 는 fd 등 정 보 를 나타 내 는데 이런 정 보 는 후기 에 직접 사 용 됩 니 다.
c = cycle->connections;
i = cycle->connection_n;
next = NULL;
do {
i--;
c[i].data = next;
c[i].read = &cycle->read_events[i];
c[i].write = &cycle->write_events[i];
c[i].fd = (ngx_socket_t) -1;
next = &c[i];
#if (NGX_THREADS)
c[i].lock = 0;
#endif
} while (i);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.