MCPcopy Create free account
hub / github.com/apache/httpd / hm_handler

Function hm_handler

modules/cluster/mod_heartmonitor.c:741–791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

739}
740
741static int hm_handler(request_rec *r)
742{
743 apr_bucket_brigade *input_brigade;
744 apr_size_t len;
745 char *buf;
746 apr_status_t status;
747 apr_table_t *tbl;
748 hm_server_t hmserver;
749 char *ip;
750 hm_ctx_t *ctx;
751
752 if (strcmp(r->handler, "heartbeat")) {
753 return DECLINED;
754 }
755 if (r->method_number != M_POST) {
756 return HTTP_METHOD_NOT_ALLOWED;
757 }
758
759 len = MAX_MSG_LEN;
760 ctx = ap_get_module_config(r->server->module_config,
761 &heartmonitor_module);
762
763 buf = apr_pcalloc(r->pool, MAX_MSG_LEN);
764 input_brigade = apr_brigade_create(r->connection->pool, r->connection->bucket_alloc);
765 status = ap_get_brigade(r->input_filters, input_brigade, AP_MODE_READBYTES, APR_BLOCK_READ, MAX_MSG_LEN);
766 if (status != APR_SUCCESS) {
767 return ap_map_http_request_error(status, HTTP_BAD_REQUEST);
768 }
769 apr_brigade_flatten(input_brigade, buf, &len);
770
771 /* we can't use hm_processmsg because it uses hm_get_server() */
772 buf[len] = '\0';
773 tbl = apr_table_make(r->pool, 10);
774 qs_to_table(buf, tbl, r->pool);
775 apr_sockaddr_ip_get(&ip, r->connection->client_addr);
776 hmserver.ip = ip;
777 hmserver.port = 80;
778 if (apr_table_get(tbl, "port") != NULL)
779 hmserver.port = atoi(apr_table_get(tbl, "port"));
780 hmserver.busy = atoi(apr_table_get(tbl, "busy"));
781 hmserver.ready = atoi(apr_table_get(tbl, "ready"));
782 hmserver.seen = apr_time_now();
783 hm_update_stat(ctx, &hmserver, r->pool);
784
785 ap_set_content_type_ex(r, "text/plain", 1);
786 ap_set_content_length(r, 2);
787 ap_rputs("OK", r);
788 ap_rflush(r);
789
790 return OK;
791}
792
793static void hm_register_hooks(apr_pool_t *p)
794{

Callers

nothing calls this directly

Calls 9

ap_get_module_configFunction · 0.85
ap_get_brigadeFunction · 0.85
qs_to_tableFunction · 0.85
hm_update_statFunction · 0.85
ap_set_content_type_exFunction · 0.85
ap_set_content_lengthFunction · 0.85
ap_rputsFunction · 0.85
ap_rflushFunction · 0.85

Tested by

no test coverage detected