LCOV - code coverage report
Current view: top level - source3/lib - tallocmsg.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 9 22 40.9 %
Date: 2024-04-21 15:09:00 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* 
       2             :    samba -- Unix SMB/CIFS implementation.
       3             :    Copyright (C) 2001, 2002 by Martin Pool
       4             : 
       5             :    This program is free software; you can redistribute it and/or modify
       6             :    it under the terms of the GNU General Public License as published by
       7             :    the Free Software Foundation; either version 3 of the License, or
       8             :    (at your option) any later version.
       9             : 
      10             :    This program is distributed in the hope that it will be useful,
      11             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             :    GNU General Public License for more details.
      14             : 
      15             :    You should have received a copy of the GNU General Public License
      16             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      17             : */
      18             : 
      19             : #include "replace.h"
      20             : #include "source3/include/messages.h"
      21             : #include "source3/lib/tallocmsg.h"
      22             : #include "lib/util/talloc_report_printf.h"
      23             : #include "lib/util/debug.h"
      24             : #include "lib/util/util_file.h"
      25             : 
      26       64659 : static bool pool_usage_filter(struct messaging_rec *rec, void *private_data)
      27             : {
      28       64659 :         FILE *f = NULL;
      29             : 
      30       64659 :         if (rec->msg_type != MSG_REQ_POOL_USAGE) {
      31       64424 :                 return false;
      32             :         }
      33             : 
      34           0 :         DBG_DEBUG("Got MSG_REQ_POOL_USAGE\n");
      35             : 
      36           0 :         if (rec->num_fds != 1) {
      37           0 :                 DBG_DEBUG("Got %"PRIu8" fds, expected one\n", rec->num_fds);
      38           0 :                 return false;
      39             :         }
      40             : 
      41           0 :         f = fdopen_keepfd(rec->fds[0], "w");
      42           0 :         if (f == NULL) {
      43           0 :                 DBG_DEBUG("fdopen failed: %s\n", strerror(errno));
      44           0 :                 return false;
      45             :         }
      46             : 
      47           0 :         talloc_full_report_printf(NULL, f);
      48             : 
      49           0 :         fclose(f);
      50             :         /*
      51             :          * Returning false, means messaging_dispatch_waiters()
      52             :          * won't call messaging_filtered_read_done() and
      53             :          * our messaging_filtered_read_send() stays alive
      54             :          * and will get messages.
      55             :          */
      56           0 :         return false;
      57             : }
      58             : 
      59             : /**
      60             :  * Register handler for MSG_REQ_POOL_USAGE
      61             :  **/
      62       37011 : void register_msg_pool_usage(
      63             :         TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx)
      64             : {
      65       37011 :         struct tevent_req *req = NULL;
      66             : 
      67       37011 :         req = messaging_filtered_read_send(
      68             :                 mem_ctx,
      69             :                 messaging_tevent_context(msg_ctx),
      70             :                 msg_ctx,
      71             :                 pool_usage_filter,
      72             :                 NULL);
      73       37011 :         if (req == NULL) {
      74           0 :                 DBG_WARNING("messaging_filtered_read_send failed\n");
      75           0 :                 return;
      76             :         }
      77       37011 :         DBG_INFO("Registered MSG_REQ_POOL_USAGE\n");
      78             : }

Generated by: LCOV version 1.14