Lines Matching refs:server
166 struct php_cli_server *server; member
751 …sapi_cli_server_register_variable(track_vars_array, "DOCUMENT_ROOT", client->server->document_root… in sapi_cli_server_register_variables()
778 sapi_cli_server_register_variable(track_vars_array, "SERVER_NAME", client->server->host TSRMLS_CC); in sapi_cli_server_register_variables()
781 spprintf(&tmp, 0, "%i", client->server->port); in sapi_cli_server_register_variables()
791 } else if (client->server->router) { in sapi_cli_server_register_variables()
793 spprintf(&temp, 0, "%s/%s", client->server->document_root, client->server->router); in sapi_cli_server_register_variables()
1757 …_server_request_translate_vpath(&client->request, client->server->document_root, client->server->d… in php_cli_server_client_read_request_on_message_complete()
1883 static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, int cl… in php_cli_server_client_ctor() argument
1885 client->server = server; in php_cli_server_client_ctor()
1925 static void php_cli_server_close_connection(php_cli_server *server, php_cli_server_client *client T… in php_cli_server_close_connection() argument
1930 zend_hash_index_del(&server->clients, client->sock); in php_cli_server_close_connection()
1933 static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server_client *client, in… in php_cli_server_send_error_page() argument
2014 php_cli_server_poller_add(&server->poller, POLLOUT, client->sock); in php_cli_server_send_error_page()
2029 static int php_cli_server_dispatch_script(php_cli_server *server, php_cli_server_client *client TSR… in php_cli_server_dispatch_script() argument
2033 return php_cli_server_send_error_page(server, client, 400 TSRMLS_CC); in php_cli_server_dispatch_script()
2051 static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_server_client *client T… in php_cli_server_begin_send_static() argument
2058 return php_cli_server_send_error_page(server, client, 400 TSRMLS_CC); in php_cli_server_begin_send_static()
2070 return php_cli_server_send_error_page(server, client, 500 TSRMLS_CC); in php_cli_server_begin_send_static()
2076 return php_cli_server_send_error_page(server, client, 404 TSRMLS_CC); in php_cli_server_begin_send_static()
2117 php_cli_server_poller_add(&server->poller, POLLOUT, client->sock); in php_cli_server_begin_send_static()
2122 static int php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client TSR… in php_cli_server_request_startup() argument
2140 static int php_cli_server_request_shutdown(php_cli_server *server, php_cli_server_client *client TS… in php_cli_server_request_shutdown() argument
2142 php_cli_server_close_connection(server, client TSRMLS_CC); in php_cli_server_request_shutdown()
2150 static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client TSR… in php_cli_server_dispatch_router() argument
2162 zfd.filename = server->router; in php_cli_server_dispatch_router()
2189 static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client *client TSRMLS_DC)… in php_cli_server_dispatch() argument
2198 if (server->router || !is_static_file) { in php_cli_server_dispatch()
2199 if (FAILURE == php_cli_server_request_startup(server, client TSRMLS_CC)) { in php_cli_server_dispatch()
2201 php_cli_server_close_connection(server, client TSRMLS_CC); in php_cli_server_dispatch()
2207 if (server->router) { in php_cli_server_dispatch()
2208 if (!php_cli_server_dispatch_router(server, client TSRMLS_CC)) { in php_cli_server_dispatch()
2209 php_cli_server_request_shutdown(server, client TSRMLS_CC); in php_cli_server_dispatch()
2215 if (SUCCESS == php_cli_server_dispatch_script(server, client TSRMLS_CC) in php_cli_server_dispatch()
2216 || SUCCESS != php_cli_server_send_error_page(server, client, 500 TSRMLS_CC)) { in php_cli_server_dispatch()
2220 php_cli_server_request_shutdown(server, client TSRMLS_CC); in php_cli_server_dispatch()
2224 if (server->router) { in php_cli_server_dispatch()
2236 if (SUCCESS != php_cli_server_begin_send_static(server, client TSRMLS_CC)) { in php_cli_server_dispatch()
2237 php_cli_server_close_connection(server, client TSRMLS_CC); in php_cli_server_dispatch()
2249 static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */ in php_cli_server_dtor()
2251 zend_hash_destroy(&server->clients); in php_cli_server_dtor()
2252 if (server->server_sock >= 0) { in php_cli_server_dtor()
2253 closesocket(server->server_sock); in php_cli_server_dtor()
2255 if (server->host) { in php_cli_server_dtor()
2256 pefree(server->host, 1); in php_cli_server_dtor()
2258 if (server->document_root) { in php_cli_server_dtor()
2259 pefree(server->document_root, 1); in php_cli_server_dtor()
2261 if (server->router) { in php_cli_server_dtor()
2262 pefree(server->router, 1); in php_cli_server_dtor()
2269 php_cli_server_poller_remove(&(*p)->server->poller, POLLIN | POLLOUT, (*p)->sock); in php_cli_server_client_dtor_wrapper()
2274 static int php_cli_server_ctor(php_cli_server *server, const char *addr, const char *document_root,… in php_cli_server_ctor() argument
2323 …server_sock = php_network_listen_socket(host, &port, SOCK_STREAM, &server->address_family, &server… in php_cli_server_ctor()
2330 server->server_sock = server_sock; in php_cli_server_ctor()
2332 err = php_cli_server_poller_ctor(&server->poller); in php_cli_server_ctor()
2337 php_cli_server_poller_add(&server->poller, POLLIN, server_sock); in php_cli_server_ctor()
2339 server->host = host; in php_cli_server_ctor()
2340 server->port = port; in php_cli_server_ctor()
2342 zend_hash_init(&server->clients, 0, NULL, (void(*)(void*))php_cli_server_client_dtor_wrapper, 1); in php_cli_server_ctor()
2351 server->document_root = _document_root; in php_cli_server_ctor()
2352 server->document_root_len = document_root_len; in php_cli_server_ctor()
2362 server->router = _router; in php_cli_server_ctor()
2363 server->router_len = router_len; in php_cli_server_ctor()
2365 server->router = NULL; in php_cli_server_ctor()
2366 server->router_len = 0; in php_cli_server_ctor()
2369 server->is_running = 1; in php_cli_server_ctor()
2388 static int php_cli_server_recv_event_read_request(php_cli_server *server, php_cli_server_client *cl… in php_cli_server_recv_event_read_request() argument
2395 php_cli_server_close_connection(server, client TSRMLS_CC); in php_cli_server_recv_event_read_request()
2398 return php_cli_server_send_error_page(server, client, 501 TSRMLS_CC); in php_cli_server_recv_event_read_request()
2400 php_cli_server_poller_remove(&server->poller, POLLIN, client->sock); in php_cli_server_recv_event_read_request()
2401 php_cli_server_dispatch(server, client TSRMLS_CC); in php_cli_server_recv_event_read_request()
2403 php_cli_server_poller_add(&server->poller, POLLIN, client->sock); in php_cli_server_recv_event_read_request()
2409 static int php_cli_server_send_event(php_cli_server *server, php_cli_server_client *client TSRMLS_D… in php_cli_server_send_event() argument
2415 php_cli_server_close_connection(server, client TSRMLS_CC); in php_cli_server_send_event()
2427 php_cli_server_close_connection(server, client TSRMLS_CC); in php_cli_server_send_event()
2432 php_cli_server_close_connection(server, client TSRMLS_CC); in php_cli_server_send_event()
2443 php_cli_server *server; member
2454 php_cli_server *server = params->server; in php_cli_server_do_event_for_each_fd_callback() local
2455 if (server->server_sock == fd) { in php_cli_server_do_event_for_each_fd_callback()
2458 socklen_t socklen = server->socklen; in php_cli_server_do_event_for_each_fd_callback()
2459 struct sockaddr *sa = pemalloc(server->socklen, 1); in php_cli_server_do_event_for_each_fd_callback()
2463 client_sock = accept(server->server_sock, sa, &socklen); in php_cli_server_do_event_for_each_fd_callback()
2477 …cli_server_client), 1)) || FAILURE == php_cli_server_client_ctor(client, server, client_sock, sa, … in php_cli_server_do_event_for_each_fd_callback()
2486 zend_hash_index_update(&server->clients, client_sock, &client, sizeof(client), NULL); in php_cli_server_do_event_for_each_fd_callback()
2487 php_cli_server_recv_event_read_request(server, client TSRMLS_CC); in php_cli_server_do_event_for_each_fd_callback()
2490 if (SUCCESS == zend_hash_index_find(&server->clients, fd, (void **)&client)) { in php_cli_server_do_event_for_each_fd_callback()
2492 params->rhandler(server, *client TSRMLS_CC); in php_cli_server_do_event_for_each_fd_callback()
2495 params->whandler(server, *client TSRMLS_CC); in php_cli_server_do_event_for_each_fd_callback()
2502 static void php_cli_server_do_event_for_each_fd(php_cli_server *server, int(*rhandler)(php_cli_serv… in php_cli_server_do_event_for_each_fd() argument
2508 server, in php_cli_server_do_event_for_each_fd()
2513 …php_cli_server_poller_iter_on_active(&server->poller, ¶ms, php_cli_server_do_event_for_each_fd… in php_cli_server_do_event_for_each_fd()
2516 static int php_cli_server_do_event_loop(php_cli_server *server TSRMLS_DC) /* {{{ */ in php_cli_server_do_event_loop()
2519 while (server->is_running) { in php_cli_server_do_event_loop()
2521 int n = php_cli_server_poller_poll(&server->poller, &tv); in php_cli_server_do_event_loop()
2523 php_cli_server_do_event_for_each_fd(server, in php_cli_server_do_event_loop()
2543 static php_cli_server server; variable
2547 server.is_running = 0; in php_cli_server_sigint_handler()
2602 …if (FAILURE == php_cli_server_ctor(&server, server_bind_address, document_root, router TSRMLS_CC))… in do_cli_server()
2624 php_cli_server_do_event_loop(&server TSRMLS_CC); in do_cli_server()
2625 php_cli_server_dtor(&server TSRMLS_CC); in do_cli_server()