Lines Matching refs:session

51 	t_session *session;  member
58 t_session *session; member
73 static int send_code(t_session *session) { in send_code() argument
76 if ((result = send_http_code_header(session)) != 0) { in send_code()
80 if (((session->return_code >= 100) && (session->return_code < 200)) || in send_code()
81 (session->return_code == 204) || (session->return_code == 304)) { in send_code()
82 if (send_buffer(session, hs_conlen, 16) == -1) { in send_code()
85 return send_buffer(session, "0\r\n\r\n", 5); in send_code()
89 if (session->host->error_xslt_file != NULL) { in send_code()
90 if (show_http_code_body(session) == 0) { in send_code()
96 return send_http_code_body(session); in send_code()
101 static t_cgi_type check_target_is_cgi(t_session *session) { in check_target_is_cgi() argument
104 session->cgi_handler = NULL; in check_target_is_cgi()
106 …if ((session->fcgi_server = find_fcgi_server(session->config->fcgi_server, session->toolkit_fastcg… in check_target_is_cgi()
107 session->cgi_type = fastcgi; in check_target_is_cgi()
108 session->host->execute_cgi = true; in check_target_is_cgi()
111 …if ((session->fcgi_server = fcgi_server_match(session->host->fcgi_server, session->extension)) != … in check_target_is_cgi()
112 session->cgi_type = fastcgi; in check_target_is_cgi()
113 } else if (in_charlist(session->extension, &(session->config->cgi_extension))) { in check_target_is_cgi()
114 session->cgi_type = binary; in check_target_is_cgi()
116 session->cgi_type = no_cgi; in check_target_is_cgi()
117 cgi = session->config->cgi_handler; in check_target_is_cgi()
119 if (in_charlist(session->extension, &(cgi->extension))) { in check_target_is_cgi()
120 session->cgi_handler = cgi->handler; in check_target_is_cgi()
121 session->cgi_type = script; in check_target_is_cgi()
128 return session->cgi_type; in check_target_is_cgi()
133 static int handle_error(t_session *session, int error_code) { in handle_error() argument
141 error_handler = session->host->error_handlers; in handle_error()
153 session->return_code = error_code; in handle_error()
154 session->error_code = error_code; in handle_error()
155 session->handling_error = true; in handle_error()
156 session->mimetype = NULL; in handle_error()
157 session->vars = error_handler->parameters; in handle_error()
158 session->encode_gzip = false; in handle_error()
160 …if ((new_fod = (char*)malloc(session->host->website_root_len + strlen(error_handler->handler) + 1)… in handle_error()
161 log_error_session(session, "malloc() error while handling error"); in handle_error()
165 if (session->file_on_disk != NULL) { in handle_error()
166 free(session->file_on_disk); in handle_error()
168 session->file_on_disk = new_fod; in handle_error()
170 memcpy(session->file_on_disk, session->host->website_root, session->host->website_root_len); in handle_error()
171 strcpy(session->file_on_disk + session->host->website_root_len, error_handler->handler); in handle_error()
173 if (get_target_extension(session) == -1) { in handle_error()
176 check_target_is_cgi(session); in handle_error()
178 if (session->cgi_type != no_cgi) { in handle_error()
179 result = execute_cgi(session); in handle_error()
181 } else if ((xslt_file = find_xslt_file(session)) != NULL) { in handle_error()
182 result = handle_xml_file(session, xslt_file); in handle_error()
185 } else switch (file_type(session->file_on_disk)) { in handle_error()
193 result = send_file(session); in handle_error()
206 log_error_session(session, "ErrorHandler is a directory"); in handle_error()
209 log_error_session(session, "no access to ErrorHandler"); in handle_error()
212 log_error_session(session, "ErrorHandler not found"); in handle_error()
215 log_error_file(session, error_handler->handler, "internal error for ErrorHandler"); in handle_error()
216 session->keep_alive = false; in handle_error()
219 log_error_file(session, error_handler->handler, "FastCGI for ErrorHandler not available"); in handle_error()
228 static int run_program(t_session *session, char *program, int return_code) { in run_program() argument
234 log_error_file(session, program, "fork() error"); in run_program()
238 log_error_file(session, program, "setsid() error"); in run_program()
242 close_bindings(session->config->binding); in run_program()
244 close_logfiles_for_cgi_run(session->config->first_host); in run_program()
248 setenv("REQUEST_METHOD", session->method, 1); in run_program()
249 setenv("DOCUMENT_ROOT", session->host->website_root, 1); in run_program()
250 setenv("REQUEST_URI", session->request_uri, 1); in run_program()
251 if (session->remote_user != NULL) { in run_program()
252 setenv("REMOTE_USER", session->remote_user, 1); in run_program()
254 …if (inet_ntop(session->ip_address.family, &(session->ip_address.value), ip, MAX_IP_STR_LEN) != NUL… in run_program()
260 http_header_to_environment(session, NULL, "Origin:", "HTTP_ORIGIN"); in run_program()
261 http_header_to_environment(session, NULL, "Range:", "HTTP_RANGE"); in run_program()
262 http_header_to_environment(session, NULL, "Referer:", "HTTP_REFERER"); in run_program()
263 http_header_to_environment(session, NULL, "User-Agent:", "HTTP_USER_AGENT"); in run_program()
269 if ((pos == NULL) && (session->config->platform == windows)) { in run_program()
285 log_error_file(session, program, "exec() error"); in run_program()
289 if (session->config->wait_for_cgi) { in run_program()
297 static t_access allow_client(t_session *session) { in allow_client() argument
301 if (session->letsencrypt_auth_request) { in allow_client()
305 if ((access = ip_allowed(&(session->ip_address), session->host->access_list)) != allow) { in allow_client()
307 } else if (last_forwarded_ip(session->http_headers, &forwarded_ip) == -1) { in allow_client()
309 } else if (ip_allowed(&forwarded_ip, session->host->access_list) == deny) { in allow_client()
317 static int process_url_toolkit(t_session *session, t_url_toolkit *toolkit, t_toolkit_options *toolk… in process_url_toolkit() argument
320 if ((result = use_toolkit(session->uri, toolkit, toolkit_options)) == UT_ERROR) { in process_url_toolkit()
325 session->log_request = false; in process_url_toolkit()
328 …if ((toolkit_options->ban > 0) && (ip_allowed(&(session->ip_address), session->config->banlist_mas… in process_url_toolkit()
329 ban_ip(&(session->ip_address), toolkit_options->ban, session->config->kick_on_ban); in process_url_toolkit()
330 log_system_session(session, "Client banned because of URL match in UrlToolkit rule"); in process_url_toolkit()
331 session->keep_alive = false; in process_url_toolkit()
333 if (session->config->monitor_enabled) { in process_url_toolkit()
334 monitor_count_ban(session); in process_url_toolkit()
340 session->toolkit_fastcgi = toolkit_options->fastcgi_server; in process_url_toolkit()
343 if (register_tempdata(&(session->tempdata), toolkit_options->new_url, tc_data) == -1) { in process_url_toolkit()
345 log_error_session(session, "error registering temporary data"); in process_url_toolkit()
348 session->uri = toolkit_options->new_url; in process_url_toolkit()
352 if ((session->location = strdup(toolkit_options->new_url)) == NULL) { in process_url_toolkit()
355 session->cause_of_30x = location; in process_url_toolkit()
360 log_error_session(session, "access denied via URL toolkit rule"); in process_url_toolkit()
365 log_error_session(session, "not found faked via URL toolkit rule"); in process_url_toolkit()
379 static int serve_client(t_session *session) { argument
400 session->current_task = "fetch & parse request";
403 if ((result = fetch_request(session)) != 200) {
404 session->request_method = GET;
406 …} else if ((result = parse_request(session, session->header_length + session->content_length)) != …
407 session->request_method = GET;
412 session->current_task = "serve client";
415 session->time = time(NULL);
416session->letsencrypt_auth_request = (strncmp(session->request_uri, "/.well-known/acme-challenge/",…
420 if (session->via_trusted_proxy) {
421 if (last_forwarded_ip(session->http_headers, &ip_addr) == 0) {
422 if (reposition_client(session, &ip_addr) != -1) {
423 copy_ip(&(session->ip_address), &ip_addr);
425 if (session->request_limit == false) {
426 connections_per_ip = session->config->total_connections;
428 connections_per_ip = session->config->connections_per_ip;
431 …if ((total_connections = connection_allowed(&ip_addr, false, connections_per_ip, session->config->…
432 session->keep_alive = false;
433 return handle_connection_not_allowed(session, total_connections);
442 if (session->request_method == CONNECT) {
443 if (in_iplist(session->config->tunnel_ssh_iplist, &(session->ip_address)) != false) {
447 if (session->config->tunnel_ssh_credential != NULL) {
448 if ((header = get_http_header("Proxy-Authorization:", session->http_headers)) != NULL) {
449 if (strcmp(header, session->config->tunnel_ssh_credential) == 0) {
460 if (session->binding->use_tls) {
465 if (strcmp(session->request_uri, "localhost:22") != 0) {
466 if (strcmp(session->request_uri, "127.0.0.1:22") != 0) {
467 if (strcmp(session->request_uri, "::1.22") != 0) {
473 log_system_session(session, "SSH tunnel requested");
474 if (tunnel_ssh_connection(session->client_socket) != 0) {
475 log_system_session(session, "SSH tunnel failed");
477 log_system_session(session, "SSH tunnel terminated");
480 session->keep_alive = false;
488 if (session->config->challenge_threshold >= 0) {
489 if (ip_allowed(&(session->ip_address), session->config->banlist_mask) != deny) {
495 if (total_connections >= session->config->challenge_threshold) {
497 log_system_session(session, "ChallengeClient mode activated");
500 if (total_connections < 0.9 * session->config->challenge_threshold) {
502 log_system_session(session, "ChallengeClient mode deactivated");
507 if ((result = challenge_client(session)) != 0) {
508 if ((result != 200) && (session->config->challenge_ban > 0)) {
509 ban_ip(&(session->ip_address), session->config->challenge_ban, session->config->kick_on_ban);
510 log_system_session(session, "Client banned due to challenge failure");
512 if (session->config->monitor_enabled) {
513 monitor_count_ban(session);
517 session->keep_alive = false;
528 if (session->hostname != NULL) {
529 if (remove_port_from_hostname(session) == -1) {
530 log_error_session(session, "error removing port from hostname");
534 …if ((host_record = get_hostrecord(session->config->first_host, session->hostname, session->binding…
535 session->host = host_record;
537 session->last_host = host_record;
541 session->host->access_time = session->time;
547 if (session->binding->use_tls) {
548 …if ((session->host->ca_certificate != NULL) && (tls_has_peer_cert(&(session->tls_context)) == fals…
549 log_error_session(session, "Missing client TLS certificate");
557 if (session->host->enforce_first_hostname && (session->hostname != NULL)) {
558 if (**(session->host->hostname.item) != '*') {
559 if (strcmp(session->hostname, *(session->host->hostname.item)) != 0) {
560 session->cause_of_30x = enforce_first_hostname;
569 …if (session->host->require_tls && (session->binding->use_tls == false) && (session->letsencrypt_au…
570 if ((qmark = strchr(session->uri, '?')) != NULL) {
572 session->vars = qmark + 1;
573 session->uri_len = strlen(session->uri);
575 session->cause_of_30x = require_tls;
582 if (session->body != NULL) {
583 chr = *(session->body + session->content_length);
584 *(session->body + session->content_length) = '\0';
586 deny_body = session->host->deny_body;
588 if (strpcmp(session->body, &(deny_body->pattern)) == 0) {
589 …if ((session->config->ban_on_denied_body > 0) && (ip_allowed(&(session->ip_address), session->conf…
590 … ban_ip(&(session->ip_address), session->config->ban_on_denied_body, session->config->kick_on_ban);
591 log_system_session(session, "Client banned because of denied body");
592 session->keep_alive = false;
594 if (session->config->monitor_enabled) {
595 monitor_count_ban(session);
600 log_exploit_attempt(session, "denied body", session->body);
605 if (session->config->monitor_enabled) {
606 monitor_count_exploit_attempt(session);
607 monitor_event("Request body denied for %s", session->host->hostname.item[0]);
611 *(session->body + session->content_length) = chr;
618 *(session->body + session->content_length) = chr;
622 if (session->letsencrypt_auth_request == false) {
623 rproxy = select_rproxy(session->host->rproxy, session->uri
625 , session->binding->use_tls
633 if ((session->request_method == GET) && (session->host->websockets != NULL)) {
634 if ((header = get_http_header("Connection:", session->http_headers)) == NULL) {
638 } else if ((header = get_http_header("Upgrade:", session->http_headers)) == NULL) {
644 switch (access = allow_client(session)) {
646 log_error_session(session, fb_accesslist);
652 if ((auth_result = http_authentication_result(session, access == unspecified)) != 200) {
657 session->keep_alive = false;
658 if ((result = forward_to_websocket(session)) != 0) {
662 session->return_code = 101;
673 switch (session->request_method) {
675 if (session->binding->enable_trace == false) {
678 return handle_trace_request(session);
681 if ((session->binding->enable_alter == false) && (session->host->webdav_app == false)) {
688 if (session->host->webdav_app == false) {
696 if (duplicate_host(session) == false) {
697 log_error_session(session, "duplicate_host() error");
702 if (session->host->use_local_config) {
703 if (load_user_root_config(session) == -1) {
712 if (session->letsencrypt_auth_request) {
719 toolkit_options.method = session->method;
720 toolkit_options.website_root = session->host->website_root;
721 toolkit_options.url_toolkit = session->config->url_toolkit;
722 toolkit_options.allow_dot_files = session->host->allow_dot_files;
723 toolkit_options.http_headers = session->http_headers;
727 toolkit_options.use_tls = session->binding->use_tls;
730 …toolkit_rules = (session->host->toolkit_rules_user != NULL) ? session->host->toolkit_rules_user :
736 result = process_url_toolkit(session, toolkit_rules[i], &toolkit_options);
752 if ((qmark = strchr(session->uri, '?')) != NULL) {
754 session->vars = qmark + 1;
760 url_decode(session->uri);
761 session->uri_len = strlen(session->uri);
763 if ((session->vars != NULL) && (session->host->secure_url)) {
764 if (forbidden_chars_present(session->vars)) {
765 log_error_session(session, "URL contains forbidden characters");
773 if (validate_url(session) == false) {
781 if (rproxy_loop_detected(session->http_headers)) {
785 switch (access = allow_client(session)) {
787 log_error_session(session, fb_accesslist);
793 if ((auth_result = http_authentication_result(session, access == unspecified)) != 200) {
800 if (session->host->prevent_sqli != p_no) {
801 result = prevent_sqli(session);
802 if ((result > 0) && (session->host->prevent_sqli >= p_prevent)) {
803 session->error_cause = ec_SQL_INJECTION;
812 if (session->host->prevent_xss != p_no) {
813 if ((prevent_xss(session) > 0) && (session->host->prevent_xss == p_block)) {
814 session->error_cause = ec_XSS;
821 if (session->host->prevent_csrf != p_no) {
822 if ((prevent_csrf(session) > 0) && (session->host->prevent_csrf == p_block)) {
823 session->error_cause = ec_CSRF;
828 return proxy_request(session, rproxy);
832 if ((result = uri_to_path(session)) != 200) {
836 if (get_target_extension(session) == -1) {
842 if (session->host->use_local_config) {
843 if (load_user_config(session) == -1) {
848 if ((result = copy_directory_settings(session)) != 200) {
852 switch (access = allow_client(session)) {
854 log_error_session(session, fb_accesslist);
860 if ((auth_result = http_authentication_result(session, access == unspecified)) != 200) {
865 switch (file_type(session->file_on_disk)) {
871 session->uri_is_dir = true;
874 …if (((session->request_method != PUT) || session->host->webdav_app) && (session->host->enable_path…
875 if ((result = get_path_info(session)) != 200) {
879 if (get_target_extension(session) == -1) {
885 log_error_session(session, fb_filesystem);
888 if ((session->request_method == DELETE) && (session->host->webdav_app == false)) {
894 if ((session->toolkit_fastcgi == NULL) && session->uri_is_dir) {
896 if (session->uri_is_dir) {
898 length = strlen(session->file_on_disk);
899 if (*(session->file_on_disk + length - 1) == '/') {
900 strcpy(session->file_on_disk + length, session->host->start_file);
902 if (get_target_extension(session) == -1) {
910 …if (((session->request_method != PUT) && (session->request_method != DELETE)) || session->host->we…
911 check_target_is_cgi(session);
916 request_method = session->request_method;
917 if (session->host->webdav_app) {
926 if (session->cgi_type != no_cgi) {
927 session->body = NULL;
928 result = execute_cgi(session);
930 } else if ((xslt_file = find_xslt_file(session)) != NULL) {
931 result = handle_xml_file(session, xslt_file);
935 result = send_file(session);
939 if ((session->host->show_index != NULL) && (session->uri[session->uri_len - 1] == '/')) {
940 result = show_index(session);
944 } else if (session->config->monitor_enabled) {
945 if ((result == 200) && (session->host->monitor_host)) {
946 unlink(session->file_on_disk);
951 …if ((session->request_method == GET) && (session->cgi_type == no_cgi) && (session->directory != NU…
952 if (session->directory->run_on_download != NULL) {
953 run_program(session, session->directory->run_on_download, result);
959 if (session->cgi_type != no_cgi) {
960 result = execute_cgi(session);
962 } else if ((xslt_file = find_xslt_file(session)) != NULL) {
963 result = handle_xml_file(session, xslt_file);
971 result = handle_put_request(session);
972 if (((result == 201) || (result == 204)) && (session->host->run_on_alter != NULL)) {
973 run_program(session, session->host->run_on_alter, result);
977 result = handle_delete_request(session);
978 if ((result == 204) && (session->host->run_on_alter != NULL)) {
979 run_program(session, session->host->run_on_alter, result);
983 send_code(session);
994 static void handle_timeout(t_session *session) { argument
995 …if ((session->config->ban_on_timeout > 0) && (ip_allowed(&(session->ip_address), session->config->…
996 ban_ip(&(session->ip_address), session->config->ban_on_timeout, session->config->kick_on_ban);
997 log_system_session(session, "Client banned because of connection timeout");
998 session->keep_alive = false;
1000 if (session->config->monitor_enabled) {
1001 monitor_count_ban(session);
1004 } else if (session->config->log_timeouts) {
1005 log_system_session(session, "Timeout while waiting for first request");
1011 static void handle_request_result(t_session *session, int result) { argument
1015 session->current_task = "handle request result";
1018 if (result == -1) switch (session->error_cause) {
1020 log_system_session(session, "Maximum request size reached");
1021 session->return_code = 413;
1022 send_code(session);
1023 …if ((session->config->ban_on_max_request_size > 0) && (ip_allowed(&(session->ip_address), session-…
1024 …ban_ip(&(session->ip_address), session->config->ban_on_max_request_size, session->config->kick_on_…
1025 log_system_session(session, "Client banned because of sending a too large request");
1026 session->keep_alive = false;
1028 if (session->config->monitor_enabled) {
1029 monitor_count_ban(session);
1035 if (session->kept_alive == 0) {
1036 session->return_code = 408;
1037 send_code(session);
1038 handle_timeout(session);
1042 if ((session->kept_alive == 0) && session->config->log_timeouts) {
1043 log_system_session(session, "Silent client disconnected");
1048 log_system_session(session, "Error while reading request");
1052 if (session->log_request) {
1053 log_request(session);
1057 if (session->config->log_timeouts) {
1058 log_system_session(session, "Client kicked");
1062 …if ((session->config->ban_on_sqli > 0) && (ip_allowed(&(session->ip_address), session->config->ban…
1063 ban_ip(&(session->ip_address), session->config->ban_on_sqli, session->config->kick_on_ban);
1064 hostname = (session->hostname != NULL) ? session->hostname : unknown_host;
1065 log_system_session(session, "Client banned because of SQL injection at %s", hostname);
1066 session->keep_alive = false;
1068 if (session->config->monitor_enabled) {
1069 monitor_count_ban(session);
1073 if (session->host->prevent_sqli == p_block) {
1074 session->return_code = 441;
1076 session->return_code = 404;
1079 send_code(session);
1080 if (session->log_request) {
1081 log_request(session);
1085 session->return_code = 442;
1086 send_code(session);
1087 if (session->log_request) {
1088 log_request(session);
1092 session->return_code = 443;
1093 send_code(session);
1094 if (session->log_request) {
1095 log_request(session);
1099 …if ((session->config->ban_on_invalid_url > 0) && (ip_allowed(&(session->ip_address), session->conf…
1100 … ban_ip(&(session->ip_address), session->config->ban_on_invalid_url, session->config->kick_on_ban);
1101 hostname = (session->hostname != NULL) ? session->hostname : unknown_host;
1102 log_system_session(session, "Client banned because of invalid URL on %s", hostname);
1103 session->keep_alive = false;
1105 if (session->config->monitor_enabled) {
1106 monitor_count_ban(session);
1110 send_code(session);
1113 if (session->data_sent == false) {
1114 session->return_code = 500;
1115 if (send_code(session) == -1) {
1116 session->keep_alive = false;
1126 if (session->data_sent == false) {
1127 session->return_code = result;
1128 if (send_header(session) == -1) {
1129 session->keep_alive = false;
1130 } else if (send_buffer(session, "Content-Length: 0\r\n\r\n", 21) == -1) {
1131 session->keep_alive = false;
1137 session->keep_alive = false;
1138 if (session->data_sent == false) {
1139 session->return_code = result;
1140 if (send_header(session) == -1) {
1141 session->keep_alive = false;
1142 } else if (send_buffer(session, "Content-Length: 0\r\n\r\n", 21) == -1) {
1143 session->keep_alive = false;
1148 log_garbage(session);
1149 if (session->data_sent == false) {
1150 session->return_code = 400;
1151 if (send_code(session) == -1) {
1152 session->keep_alive = false;
1155 …if ((session->config->ban_on_garbage > 0) && (ip_allowed(&(session->ip_address), session->config->…
1156 ban_ip(&(session->ip_address), session->config->ban_on_garbage, session->config->kick_on_ban);
1157 log_system_session(session, "Client banned because of sending garbage");
1158 session->keep_alive = false;
1160 if (session->config->monitor_enabled) {
1161 monitor_count_ban(session);
1166 if (session->config->monitor_enabled) {
1167 monitor_count_bad_request(session);
1176 if (session->data_sent == false) {
1177 switch (handle_error(session, result)) {
1179 session->keep_alive = false;
1184 if (session->data_sent == false) {
1185 session->return_code = result;
1186 if (send_code(session) == -1) {
1187 session->keep_alive = false;
1194 session->keep_alive = false;
1196 if (session->data_sent == false) {
1197 session->return_code = result;
1198 send_code(session);
1203 if (session->log_request) {
1204 log_request(session);
1207 session->keep_alive = false;
1213 static void connection_handler(t_session *session) { argument
1220 session->current_task = "thread started";
1224 if (session->binding->use_tls) {
1226 session->current_task = "ssl accept";
1229 …timeout = session->kept_alive == 0 ? session->binding->time_for_1st_request : session->binding->ti…
1230 …switch (tls_accept(&(session->client_socket), &(session->tls_context), session->binding->tls_confi…
1234 log_system_session(session, "No cypher overlap during TLS handshake.");
1237 handle_timeout(session);
1240 session->socket_open = true;
1245 session->socket_open = true;
1247 if (session->socket_open) {
1249 if (session->config->monitor_enabled) {
1250 monitor_count_connection(session);
1255 result = serve_client(session);
1256 handle_request_result(session, result);
1258 if (session->parsing_oke) {
1259 …show_request_to_admins(session->method, session->request_uri, session->http_version, &(session->ip…
1260 session->http_headers, session->return_code, session->bytes_sent);
1265 session->current_task = "request done";
1268 if (session->socket_open) {
1271 if (send_buffer(session, NULL, 0) == -1) {
1272 session->keep_alive = false;
1277 if (session->config->monitor_enabled) {
1278 monitor_count_host(session);
1281 reset_session(session);
1283 session->current_task = "session reset";
1286 if ((session->kept_alive > 0) && (session->config->ban_on_flooding > 0)) {
1287 if (client_is_flooding(session)) {
1288 if (ip_allowed(&(session->ip_address), session->config->banlist_mask) != deny) {
1289 … ban_ip(&(session->ip_address), session->config->ban_on_flooding, session->config->kick_on_ban);
1290 log_system_session(session, "Client banned because of flooding");
1291 session->keep_alive = false;
1293 if (session->config->monitor_enabled) {
1294 monitor_count_ban(session);
1300 } while (session->keep_alive && session->socket_open);
1302 session->current_task = "session done";
1305 destroy_session(session);
1306 close_socket(session);
1308 close(session->client_socket);
1311 if (session->config->reconnect_delay > 0) {
1312 mark_client_for_removal(session, session->config->reconnect_delay);
1314 remove_client(session);
1315 free(session);
1336 t_session *session; local
1353 session = list->session;
1356 return session;
1362 t_session *session; local
1366 if (self->session == NULL) {
1372 session = NULL;
1374 session = last_session(session_list);
1379 session = self->session;
1380 self->session = NULL;
1383 if (session != NULL) {
1384 if (add_client(session) == 0) {
1385 connection_handler(session);
1387 close(session->client_socket);
1388 free(session);
1420 static int add_thread_to_pool(t_session *session) { argument
1428 new_thread->session = session;
1464 int start_worker(t_session *session) { argument
1471 log_system_session(session, "pthread init error");
1474 log_system_session(session, "pthread set detach state error");
1476 log_system_session(session, "pthread set stack size error");
1477 } else if (add_client(session) == 0) {
1478 if (pthread_create(&child_thread, &child_attr, (void*)connection_handler, (void*)session) == 0) {
1483 remove_client(session);
1484 log_system_session(session, "pthread create error");
1498 if (add_thread_to_pool(session) == -1) {
1504 new_session->session = session;