Lines Matching defs:peer

18 static char *ngx_syslog_parse_args(ngx_conf_t *cf, ngx_syslog_peer_t *peer);
19 static ngx_int_t ngx_syslog_init_peer(ngx_syslog_peer_t *peer);
40 ngx_syslog_process_conf(ngx_conf_t *cf, ngx_syslog_peer_t *peer)
42 peer->pool = cf->pool;
43 peer->facility = NGX_CONF_UNSET_UINT;
44 peer->severity = NGX_CONF_UNSET_UINT;
46 if (ngx_syslog_parse_args(cf, peer) != NGX_CONF_OK) {
50 if (peer->server.sockaddr == NULL) {
56 if (peer->facility == NGX_CONF_UNSET_UINT) {
57 peer->facility = 23; /* local7 */
60 if (peer->severity == NGX_CONF_UNSET_UINT) {
61 peer->severity = 6; /* info */
64 if (peer->tag.data == NULL) {
65 ngx_str_set(&peer->tag, "nginx");
68 peer->conn.fd = (ngx_socket_t) -1;
75 ngx_syslog_parse_args(ngx_conf_t *cf, ngx_syslog_peer_t *peer)
100 if (peer->server.sockaddr != NULL) {
122 peer->server = u.addrs[0];
126 if (peer->facility != NGX_CONF_UNSET_UINT) {
135 peer->facility = i;
146 if (peer->severity != NGX_CONF_UNSET_UINT) {
155 peer->severity = i;
166 if (peer->tag.data != NULL) {
194 peer->tag.data = p + 4;
195 peer->tag.len = len - 4;
198 peer->nohostname = 1;
220 ngx_syslog_add_header(ngx_syslog_peer_t *peer, u_char *buf)
224 pri = peer->facility * 8 + peer->severity;
226 if (peer->nohostname) {
228 &peer->tag);
232 &ngx_cycle->hostname, &peer->tag);
242 ngx_syslog_peer_t *peer;
244 peer = log->wdata;
246 if (peer->busy) {
250 peer->busy = 1;
251 peer->severity = level - 1;
253 p = ngx_syslog_add_header(peer, msg);
264 (void) ngx_syslog_send(peer, msg, p - msg);
266 peer->busy = 0;
271 ngx_syslog_send(ngx_syslog_peer_t *peer, u_char *buf, size_t len)
275 if (peer->conn.fd == (ngx_socket_t) -1) {
276 if (ngx_syslog_init_peer(peer) != NGX_OK) {
282 peer->conn.log = ngx_cycle->log;
285 n = ngx_send(&peer->conn, buf, len);
289 n = ngx_os_io.send(&peer->conn, buf, len);
294 if (n == NGX_ERROR && peer->server.sockaddr->sa_family == AF_UNIX) {
296 if (ngx_close_socket(peer->conn.fd) == -1) {
301 peer->conn.fd = (ngx_socket_t) -1;
311 ngx_syslog_init_peer(ngx_syslog_peer_t *peer)
316 peer->conn.read = &ngx_syslog_dummy_event;
317 peer->conn.write = &ngx_syslog_dummy_event;
321 fd = ngx_socket(peer->server.sockaddr->sa_family, SOCK_DGRAM, 0);
334 if (connect(fd, peer->server.sockaddr, peer->server.socklen) == -1) {
340 cln = ngx_pool_cleanup_add(peer->pool, 0);
345 cln->data = peer;
348 peer->conn.fd = fd;
351 peer->conn.write->ready = 1;
369 ngx_syslog_peer_t *peer = data;
371 /* prevents further use of this peer */
372 peer->busy = 1;
374 if (peer->conn.fd == (ngx_socket_t) -1) {
378 if (ngx_close_socket(peer->conn.fd) == -1) {