LCOV - code coverage report
Current view: top level - lib/eal/unix - eal_unix_thread.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 23 26 88.5 %
Date: 2025-03-01 20:23:48 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 28 35.7 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2022 Red Hat, Inc.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <errno.h>
       6                 :            : #include <unistd.h>
       7                 :            : 
       8                 :            : #include <rte_debug.h>
       9                 :            : 
      10                 :            : #include "eal_private.h"
      11                 :            : 
      12                 :            : int
      13                 :        194 : eal_thread_wake_worker(unsigned int worker_id)
      14                 :            : {
      15                 :        194 :         int m2w = lcore_config[worker_id].pipe_main2worker[1];
      16                 :        194 :         int w2m = lcore_config[worker_id].pipe_worker2main[0];
      17                 :        194 :         char c = 0;
      18                 :            :         int n;
      19                 :            : 
      20                 :            :         do {
      21                 :        194 :                 n = write(m2w, &c, 1);
      22   [ -  +  -  +  :        194 :         } while (n == 0 || (n < 0 && errno == EINTR));
                   -  - ]
      23         [ +  - ]:        194 :         if (n < 0)
      24                 :            :                 return -EPIPE;
      25                 :            : 
      26                 :            :         do {
      27                 :        194 :                 n = read(w2m, &c, 1);
      28   [ -  +  -  - ]:        194 :         } while (n < 0 && errno == EINTR);
      29         [ -  + ]:        194 :         if (n <= 0)
      30                 :          0 :                 return -EPIPE;
      31                 :            :         return 0;
      32                 :            : }
      33                 :            : 
      34                 :            : void
      35                 :        322 : eal_thread_wait_command(void)
      36                 :            : {
      37                 :            :         unsigned int lcore_id = rte_lcore_id();
      38                 :            :         int m2w;
      39                 :            :         char c;
      40                 :            :         int n;
      41                 :            : 
      42                 :        322 :         m2w = lcore_config[lcore_id].pipe_main2worker[0];
      43                 :            :         do {
      44                 :        194 :                 n = read(m2w, &c, 1);
      45   [ -  +  -  - ]:        194 :         } while (n < 0 && errno == EINTR);
      46         [ -  + ]:        194 :         if (n <= 0)
      47                 :          0 :                 rte_panic("cannot read on configuration pipe\n");
      48                 :        194 : }
      49                 :            : 
      50                 :            : void
      51                 :        194 : eal_thread_ack_command(void)
      52                 :            : {
      53                 :            :         unsigned int lcore_id = rte_lcore_id();
      54                 :        194 :         char c = 0;
      55                 :            :         int w2m;
      56                 :            :         int n;
      57                 :            : 
      58                 :        194 :         w2m = lcore_config[lcore_id].pipe_worker2main[1];
      59                 :            :         do {
      60                 :        194 :                 n = write(w2m, &c, 1);
      61   [ -  +  -  +  :        194 :         } while (n == 0 || (n < 0 && errno == EINTR));
                   -  - ]
      62         [ -  + ]:        194 :         if (n < 0)
      63                 :          0 :                 rte_panic("cannot write on configuration pipe\n");
      64                 :        194 : }

Generated by: LCOV version 1.14