Lines Matching refs:proc
341 fcgi_proc *proc; member
389 static void fastcgi_status_copy_procname(buffer *b, fcgi_extension_host *host, fcgi_proc *proc) { in fastcgi_status_copy_procname() argument
392 if (proc) { in fastcgi_status_copy_procname()
394 buffer_append_long(b, proc->id); in fastcgi_status_copy_procname()
400 hctx->proc->load++; in fcgi_proc_load_inc()
404 fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); in fcgi_proc_load_inc()
407 status_counter_set(srv, CONST_BUF_LEN(p->statuskey), hctx->proc->load); in fcgi_proc_load_inc()
412 hctx->proc->load--; in fcgi_proc_load_dec()
416 fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); in fcgi_proc_load_dec()
419 status_counter_set(srv, CONST_BUF_LEN(p->statuskey), hctx->proc->load); in fcgi_proc_load_dec()
448 if (hctx->host->disable_time || hctx->proc->is_local) { in fcgi_host_disable()
449 if (hctx->proc->state == PROC_STATE_RUNNING) hctx->host->active_procs--; in fcgi_host_disable()
450 hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time; in fcgi_host_disable()
451 hctx->proc->state = hctx->proc->is_local ? PROC_STATE_DIED_WAIT_FOR_PID : PROC_STATE_DIED; in fcgi_host_disable()
460 static int fastcgi_status_init(server *srv, buffer *b, fcgi_extension_host *host, fcgi_proc *proc) { in fastcgi_status_init() argument
462 fastcgi_status_copy_procname(b, host, proc); \ in fastcgi_status_init()
498 hctx->proc = NULL; in handler_ctx_init()
716 fcgi_proc *proc; in FREE_FUNC() local
721 for (proc = host->first; proc; proc = proc->next) { in FREE_FUNC()
722 if (proc->pid != 0) { in FREE_FUNC()
723 kill(proc->pid, host->kill_signal); in FREE_FUNC()
726 if (proc->is_local && in FREE_FUNC()
727 !buffer_is_empty(proc->unixsocket)) { in FREE_FUNC()
728 unlink(proc->unixsocket->ptr); in FREE_FUNC()
732 for (proc = host->unused_procs; proc; proc = proc->next) { in FREE_FUNC()
733 if (proc->pid != 0) { in FREE_FUNC()
734 kill(proc->pid, host->kill_signal); in FREE_FUNC()
736 if (proc->is_local && in FREE_FUNC()
737 !buffer_is_empty(proc->unixsocket)) { in FREE_FUNC()
738 unlink(proc->unixsocket->ptr); in FREE_FUNC()
850 fcgi_proc *proc) { in fcgi_spawn_connection() argument
868 "new proc, socket:", proc->port, proc->unixsocket); in fcgi_spawn_connection()
871 if (!buffer_is_empty(proc->unixsocket)) { in fcgi_spawn_connection()
876 strcpy(fcgi_addr_un.sun_path, proc->unixsocket->ptr); in fcgi_spawn_connection()
882 servlen = proc->unixsocket->used + sizeof(fcgi_addr_un.sun_family); in fcgi_spawn_connection()
887 buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("unix:")); in fcgi_spawn_connection()
888 buffer_append_string_buffer(proc->connection_name, proc->unixsocket); in fcgi_spawn_connection()
927 fcgi_addr_in.sin_port = htons(proc->port); in fcgi_spawn_connection()
933 buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("tcp:")); in fcgi_spawn_connection()
935 buffer_append_string_buffer(proc->connection_name, host->host); in fcgi_spawn_connection()
937 buffer_append_string_len(proc->connection_name, CONST_STR_LEN("localhost")); in fcgi_spawn_connection()
939 buffer_append_string_len(proc->connection_name, CONST_STR_LEN(":")); in fcgi_spawn_connection()
940 buffer_append_long(proc->connection_name, proc->port); in fcgi_spawn_connection()
955 !buffer_is_empty(proc->unixsocket)) { in fcgi_spawn_connection()
956 unlink(proc->unixsocket->ptr); in fcgi_spawn_connection()
979 proc->connection_name, in fcgi_spawn_connection()
1133 proc->pid = child; in fcgi_spawn_connection()
1134 proc->is_local = 1; in fcgi_spawn_connection()
1140 proc->is_local = 0; in fcgi_spawn_connection()
1141 proc->pid = 0; in fcgi_spawn_connection()
1146 proc->connection_name); in fcgi_spawn_connection()
1150 proc->state = PROC_STATE_RUNNING; in fcgi_spawn_connection()
1374 fcgi_proc *proc; in SETDEFAULTS_FUNC() local
1376 proc = fastcgi_process_init(); in SETDEFAULTS_FUNC()
1377 proc->id = host->num_procs++; in SETDEFAULTS_FUNC()
1381 proc->port = host->port + pno; in SETDEFAULTS_FUNC()
1383 buffer_copy_string_buffer(proc->unixsocket, host->unixsocket); in SETDEFAULTS_FUNC()
1384 buffer_append_string_len(proc->unixsocket, CONST_STR_LEN("-")); in SETDEFAULTS_FUNC()
1385 buffer_append_long(proc->unixsocket, pno); in SETDEFAULTS_FUNC()
1396 if (fcgi_spawn_connection(srv, p, host, proc)) { in SETDEFAULTS_FUNC()
1402 fastcgi_status_init(srv, p->statuskey, host, proc); in SETDEFAULTS_FUNC()
1404 proc->next = host->first; in SETDEFAULTS_FUNC()
1405 if (host->first) host->first->prev = proc; in SETDEFAULTS_FUNC()
1407 host->first = proc; in SETDEFAULTS_FUNC()
1410 fcgi_proc *proc; in SETDEFAULTS_FUNC() local
1412 proc = fastcgi_process_init(); in SETDEFAULTS_FUNC()
1413 proc->id = host->num_procs++; in SETDEFAULTS_FUNC()
1416 proc->state = PROC_STATE_RUNNING; in SETDEFAULTS_FUNC()
1419 proc->port = host->port; in SETDEFAULTS_FUNC()
1421 buffer_copy_string_buffer(proc->unixsocket, host->unixsocket); in SETDEFAULTS_FUNC()
1424 fastcgi_status_init(srv, p->statuskey, host, proc); in SETDEFAULTS_FUNC()
1426 host->first = proc; in SETDEFAULTS_FUNC()
1484 if (hctx->host && hctx->proc) { in fcgi_connection_close()
1492 "pid:", hctx->proc->pid, in fcgi_connection_close()
1493 "socket:", hctx->proc->connection_name, in fcgi_connection_close()
1494 "load:", hctx->proc->load); in fcgi_connection_close()
1540 if (hctx->proc) { in fcgi_reconnect()
1543 hctx->proc->pid, hctx->proc->connection_name); in fcgi_reconnect()
1551 if (hctx->proc && hctx->got_proc) { in fcgi_reconnect()
1655 fcgi_proc *proc = hctx->proc; in fcgi_establish_connection() local
1660 if (!buffer_is_empty(proc->unixsocket)) { in fcgi_establish_connection()
1664 strcpy(fcgi_addr_un.sun_path, proc->unixsocket->ptr); in fcgi_establish_connection()
1669 servlen = proc->unixsocket->used + sizeof(fcgi_addr_un.sun_family); in fcgi_establish_connection()
1673 if (buffer_is_empty(proc->connection_name)) { in fcgi_establish_connection()
1675 buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("unix:")); in fcgi_establish_connection()
1676 buffer_append_string_buffer(proc->connection_name, proc->unixsocket); in fcgi_establish_connection()
1694 fcgi_addr_in.sin_port = htons(proc->port); in fcgi_establish_connection()
1699 if (buffer_is_empty(proc->connection_name)) { in fcgi_establish_connection()
1701 buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("tcp:")); in fcgi_establish_connection()
1703 buffer_append_string_buffer(proc->connection_name, host->host); in fcgi_establish_connection()
1705 buffer_append_string_len(proc->connection_name, CONST_STR_LEN("localhost")); in fcgi_establish_connection()
1707 buffer_append_string_len(proc->connection_name, CONST_STR_LEN(":")); in fcgi_establish_connection()
1708 buffer_append_long(proc->connection_name, proc->port); in fcgi_establish_connection()
1718 "connect delayed; will continue later:", proc->connection_name); in fcgi_establish_connection()
1727 "The load for this FastCGI backend", proc->connection_name, "is", proc->load); in fcgi_establish_connection()
1735 proc->connection_name); in fcgi_establish_connection()
2497 fcgi_proc *proc = hctx->proc; in fcgi_demux_response() local
2545 "pid:", proc->pid, in fcgi_demux_response()
2546 "socket:", proc->connection_name); in fcgi_demux_response()
2705 fcgi_proc *proc; in fcgi_restart_dead_procs() local
2707 for (proc = host->first; proc; proc = proc->next) { in fcgi_restart_dead_procs()
2713 proc->connection_name, in fcgi_restart_dead_procs()
2714 proc->state, in fcgi_restart_dead_procs()
2715 proc->is_local, in fcgi_restart_dead_procs()
2716 proc->load, in fcgi_restart_dead_procs()
2717 proc->pid); in fcgi_restart_dead_procs()
2724 switch (proc->state) { in fcgi_restart_dead_procs()
2734 if (srv->cur_ts <= proc->disabled_until) break; in fcgi_restart_dead_procs()
2736 proc->state = PROC_STATE_RUNNING; in fcgi_restart_dead_procs()
2746 if (!proc->is_local) { in fcgi_restart_dead_procs()
2747 proc->state = PROC_STATE_DIED; in fcgi_restart_dead_procs()
2752 switch(waitpid(proc->pid, &status, WNOHANG)) { in fcgi_restart_dead_procs()
2755 if (srv->cur_ts <= proc->disabled_until) break; in fcgi_restart_dead_procs()
2757 proc->state = PROC_STATE_RUNNING; in fcgi_restart_dead_procs()
2771 proc->state = PROC_STATE_DIED; in fcgi_restart_dead_procs()
2777 "child exited, pid:", proc->pid, in fcgi_restart_dead_procs()
2790 proc->state = PROC_STATE_DIED; in fcgi_restart_dead_procs()
2798 if (proc->state != PROC_STATE_DIED) break; in fcgi_restart_dead_procs()
2807 if (proc->load != 0) break; in fcgi_restart_dead_procs()
2814 "\n\tsocket", proc->connection_name, in fcgi_restart_dead_procs()
2818 if (fcgi_spawn_connection(srv, p, host, proc)) { in fcgi_restart_dead_procs()
2824 if (srv->cur_ts <= proc->disabled_until) break; in fcgi_restart_dead_procs()
2826 proc->state = PROC_STATE_RUNNING; in fcgi_restart_dead_procs()
2831 proc->connection_name); in fcgi_restart_dead_procs()
2844 fcgi_proc *proc; in fcgi_write_request() local
2878 if (!hctx->proc->is_local || p->conf.debug) { in fcgi_write_request()
2883 "socket:", hctx->proc->connection_name); in fcgi_write_request()
2892 fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); in fcgi_write_request()
2910 hctx->proc = NULL; in fcgi_write_request()
2912 for (proc = hctx->host->first; in fcgi_write_request()
2913 proc && proc->state != PROC_STATE_RUNNING; in fcgi_write_request()
2914 proc = proc->next); in fcgi_write_request()
2917 if (proc == NULL) { in fcgi_write_request()
2923 hctx->proc = proc; in fcgi_write_request()
2926 for (proc = proc->next; proc; proc = proc->next) { in fcgi_write_request()
2927 if (proc->state != PROC_STATE_RUNNING) continue; in fcgi_write_request()
2928 if (proc->load < hctx->proc->load) hctx->proc = proc; in fcgi_write_request()
2959 if (hctx->proc->is_local) { in fcgi_write_request()
2960 hctx->pid = hctx->proc->pid; in fcgi_write_request()
2981 hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time; in fcgi_write_request()
2982 if (hctx->proc->state == PROC_STATE_RUNNING) hctx->host->active_procs--; in fcgi_write_request()
2983 hctx->proc->state = PROC_STATE_OVERLOADED; in fcgi_write_request()
2986 fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); in fcgi_write_request()
3007 fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); in fcgi_write_request()
3029 fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); in fcgi_write_request()
3037 "pid:", hctx->proc->pid, in fcgi_write_request()
3038 "socket:", hctx->proc->connection_name, in fcgi_write_request()
3039 "load:", hctx->proc->load); in fcgi_write_request()
3071 "socket:", hctx->proc->connection_name); in fcgi_write_request()
3172 hctx->proc = NULL; in SUBREQUEST_FUNC()
3231 fcgi_proc *proc = hctx->proc; in fcgi_handle_fdevent() local
3268 if (proc->pid && proc->state != PROC_STATE_DIED) { in fcgi_handle_fdevent()
3273 switch(waitpid(proc->pid, &status, WNOHANG)) { in fcgi_handle_fdevent()
3283 "child exited, pid:", proc->pid, in fcgi_handle_fdevent()
3298 "\n\tsocket", proc->connection_name, in fcgi_handle_fdevent()
3302 if (fcgi_spawn_connection(srv, p, host, proc)) { in fcgi_handle_fdevent()
3304 proc->state = PROC_STATE_DIED; in fcgi_handle_fdevent()
3323 "on socket:", proc->connection_name, in fcgi_handle_fdevent()
3331 "on socket:", proc->connection_name, in fcgi_handle_fdevent()
3346 "on socket:", proc->connection_name, in fcgi_handle_fdevent()
3390 hctx->proc->port == 0) { in fcgi_handle_fdevent()
3400 "(no fastcgi process on socket:", proc->connection_name, "?)", in fcgi_handle_fdevent()
3597 hctx->proc = NULL; in fcgi_check_extension()
3665 hctx->proc = NULL; in fcgi_check_extension()
3761 fcgi_proc *proc; in TRIGGER_FUNC() local
3768 for (proc = host->unused_procs; proc; proc = proc->next) { in TRIGGER_FUNC()
3771 if (proc->pid == 0) continue; in TRIGGER_FUNC()
3773 switch (waitpid(proc->pid, &status, WNOHANG)) { in TRIGGER_FUNC()
3781 "pid ", proc->pid, proc->state, in TRIGGER_FUNC()
3787 proc->pid = 0; in TRIGGER_FUNC()
3788 proc->state = PROC_STATE_UNSET; in TRIGGER_FUNC()
3796 if (proc->state != PROC_STATE_KILLED) { in TRIGGER_FUNC()
3799 WEXITSTATUS(status), proc->connection_name); in TRIGGER_FUNC()
3812 proc->pid = 0; in TRIGGER_FUNC()
3813 if (proc->state == PROC_STATE_RUNNING) host->active_procs--; in TRIGGER_FUNC()
3814 proc->state = PROC_STATE_UNSET; in TRIGGER_FUNC()