LCOV - code coverage report
Current view: top level - app/firedancer-dev/commands - ipecho_server.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 65 0.0 %
Date: 2025-09-19 04:41:14 Functions: 0 5 0.0 %

          Line data    Source code
       1             : 
       2             : #include "../../shared/commands/configure/configure.h"
       3             : #include "../../shared/commands/run/run.h"
       4             : #include "../../../disco/metrics/fd_metrics.h"
       5             : #include "../../../disco/topo/fd_topob.h"
       6             : 
       7             : #include <time.h>
       8             : #include <stdio.h>
       9             : #include <unistd.h>
      10             : 
      11             : #define NAME "ipecho-server"
      12             : 
      13             : extern fd_topo_obj_callbacks_t * CALLBACKS[];
      14             : 
      15             : fd_topo_run_tile_t
      16             : fdctl_tile_run( fd_topo_tile_t const * tile );
      17             : 
      18             : static void
      19             : ipecho_topo( fd_topo_t *  topo,
      20           0 :              char const * name ) {
      21           0 :   fd_topob_new( topo, name );
      22           0 :   topo->max_page_size = 1UL<<21UL;
      23             : 
      24           0 :   fd_topob_wksp( topo, "all" );
      25           0 :   fd_topo_link_t * link = fd_topob_link( topo, "ipecho_out", "all", 4UL, 0UL, 1UL );
      26           0 :   link->permit_no_consumers = 1;
      27           0 :   fd_topo_tile_t * tile = fd_topob_tile( topo, "ipecho", "all", "all", 0UL, 0, 0 );
      28           0 :   tile->ipecho.expected_shred_version = 32;
      29           0 :   tile->ipecho.entrypoints_cnt = 0UL;
      30           0 :   tile->ipecho.bind_address = FD_IP4_ADDR(127,0,0,1);
      31           0 :   tile->ipecho.bind_port    = 12008;
      32           0 :   fd_topob_tile_out( topo, "ipecho", 0UL, "ipecho_out", 0UL );
      33             : 
      34           0 :   fd_topob_auto_layout( topo, 0 );
      35           0 :   fd_topob_finish( topo, CALLBACKS );
      36           0 : }
      37             : 
      38             : extern int * fd_log_private_shared_lock;
      39             : 
      40             : static void
      41           0 : ipecho_server_cmd_topo( config_t * config ) {
      42           0 :   ipecho_topo( &config->topo, config->name );
      43           0 : }
      44             : 
      45             : static args_t
      46           0 : configure_args( void ) {
      47           0 :   args_t args = {
      48           0 :     .configure.command = CONFIGURE_CMD_INIT,
      49           0 :   };
      50             : 
      51           0 :   ulong stage_idx = 0UL;
      52           0 :   args.configure.stages[ stage_idx++ ] = &fd_cfg_stage_hugetlbfs;
      53           0 :   args.configure.stages[ stage_idx++ ] = NULL;
      54             : 
      55           0 :   return args;
      56           0 : }
      57             : 
      58             : void
      59             : ipecho_server_cmd_perm( args_t *    args FD_PARAM_UNUSED,
      60             :                    fd_cap_chk_t *   chk,
      61           0 :                    config_t const * config ) {
      62           0 :   args_t c_args = configure_args();
      63           0 :   configure_cmd_perm( &c_args, chk, config );
      64           0 :   run_cmd_perm( NULL, chk, config );
      65           0 : }
      66             : 
      67             : static void
      68             : ipecho_server_cmd_fn( args_t *   args,
      69           0 :                       config_t * config ) {
      70           0 :   (void)args;
      71             : 
      72           0 :   args_t c_args = configure_args();
      73           0 :   configure_cmd_fn( &c_args, config );
      74             : 
      75           0 :   run_firedancer_init( config, 1, 0 );
      76             : 
      77           0 :   fd_log_private_shared_lock[ 1 ] = 0;
      78           0 :   fd_topo_join_workspaces( &config->topo, FD_SHMEM_JOIN_MODE_READ_WRITE );
      79           0 :   fd_topo_fill( &config->topo );
      80             : 
      81           0 :   ulong tile_idx1 = fd_topo_find_tile( &config->topo, "ipecho", 0UL );
      82           0 :   fd_topo_tile_t * ipecho_tile1 = &config->topo.tiles[ tile_idx1 ];
      83           0 :   ulong volatile * const ipecho_metrics1 = fd_metrics_tile( ipecho_tile1->metrics );
      84           0 :   (void)ipecho_metrics1;
      85             : 
      86           0 :   fd_topo_run_single_process( &config->topo, 2, config->uid, config->gid, fdctl_tile_run );
      87             : 
      88           0 :   ulong tile_idx = fd_topo_find_tile( &config->topo, "ipecho", 0UL );
      89           0 :   FD_TEST( tile_idx!=ULONG_MAX );
      90           0 :   fd_topo_tile_t * ipecho_tile = &config->topo.tiles[ tile_idx ];
      91             : 
      92           0 :   sleep(1);
      93           0 :   ulong volatile * const ipecho_metrics = fd_metrics_tile( ipecho_tile->metrics );
      94             : 
      95           0 :   ulong last_conns = ULONG_MAX;
      96           0 :   ulong last_closed_ok = ULONG_MAX;
      97           0 :   ulong last_closed_error = ULONG_MAX;
      98             : 
      99           0 :   for(;;) {
     100           0 :     ulong ipecho_conns = FD_VOLATILE_CONST( ipecho_metrics[ MIDX( GAUGE, IPECHO, CONNECTION_COUNT ) ] );
     101           0 :     ulong ipecho_closed_ok = FD_VOLATILE_CONST( ipecho_metrics[ MIDX( COUNTER, IPECHO, CONNECTIONS_CLOSED_OK ) ] );
     102           0 :     ulong ipecho_closed_error = FD_VOLATILE_CONST( ipecho_metrics[ MIDX( COUNTER, IPECHO, CONNECTIONS_CLOSED_ERROR ) ] );
     103             : 
     104           0 :     if( FD_UNLIKELY( ipecho_conns!=last_conns || ipecho_closed_ok!=last_closed_ok || ipecho_closed_error!=last_closed_error ) ) {
     105           0 :       FD_LOG_NOTICE(( "connections=%lu closed_ok=%lu closed_err=%lu", ipecho_conns, ipecho_closed_ok, ipecho_closed_error ));
     106           0 :       last_conns = ipecho_conns;
     107           0 :       last_closed_ok = ipecho_closed_ok;
     108           0 :       last_closed_error = ipecho_closed_error;
     109           0 :     }
     110             : 
     111             :     nanosleep( &(struct timespec){ .tv_sec=0, .tv_nsec=1000L*1000L }, NULL );
     112           0 :   }
     113           0 : }
     114             : 
     115             : action_t fd_action_ipecho_server = {
     116             :   .name = NAME,
     117             :   .args = NULL,
     118             :   .perm = ipecho_server_cmd_perm,
     119             :   .fn   = ipecho_server_cmd_fn,
     120             :   .topo = ipecho_server_cmd_topo,
     121             : };

Generated by: LCOV version 1.14