2002-01-03 03:53:41 +00:00
/*
2002-01-30 06:08:46 +00:00
samba - - Unix SMB / CIFS implementation .
2002-01-03 05:26:57 +00:00
Copyright ( C ) 2001 , 2002 by Martin Pool
2010-01-17 13:52:53 +01:00
2002-01-03 03:53:41 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 19:25:36 +00:00
the Free Software Foundation ; either version 3 of the License , or
2002-01-03 03:53:41 +00:00
( at your option ) any later version .
2010-01-17 13:52:53 +01:00
2002-01-03 03:53:41 +00:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2010-01-17 13:52:53 +01:00
2002-01-03 03:53:41 +00:00
You should have received a copy of the GNU General Public License
2007-07-10 00:52:41 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2002-01-03 03:53:41 +00:00
*/
# include "includes.h"
2011-03-24 15:31:06 +01:00
# include "messages.h"
2019-08-30 15:08:40 +02:00
# include "lib/util/talloc_report_printf.h"
2002-01-03 03:53:41 +00:00
2019-08-30 15:08:40 +02:00
static bool pool_usage_filter ( struct messaging_rec * rec , void * private_data )
2019-03-29 12:44:50 +01:00
{
2020-02-11 21:26:18 +01:00
FILE * f = NULL ;
int fd ;
2019-08-30 15:08:40 +02:00
if ( rec - > msg_type ! = MSG_REQ_POOL_USAGE ) {
return false ;
}
DBG_DEBUG ( " Got MSG_REQ_POOL_USAGE \n " ) ;
2019-03-29 12:44:50 +01:00
2019-08-30 15:08:40 +02:00
if ( rec - > num_fds ! = 1 ) {
DBG_DEBUG ( " Got % " PRIu8 " fds, expected one \n " , rec - > num_fds ) ;
return false ;
}
2020-02-11 21:26:18 +01:00
fd = dup ( rec - > fds [ 0 ] ) ;
if ( fd = = - 1 ) {
DBG_DEBUG ( " dup(% " PRIi64 " ) failed: %s \n " ,
rec - > fds [ 0 ] ,
strerror ( errno ) ) ;
return false ;
2019-03-29 12:30:45 +01:00
}
2020-02-11 21:26:18 +01:00
f = fdopen ( fd , " w " ) ;
2019-08-30 15:08:40 +02:00
if ( f = = NULL ) {
DBG_DEBUG ( " fdopen failed: %s \n " , strerror ( errno ) ) ;
2020-02-11 21:26:18 +01:00
close ( fd ) ;
return false ;
2019-03-29 12:44:50 +01:00
}
2019-08-30 15:08:40 +02:00
talloc_full_report_printf ( NULL , f ) ;
fclose ( f ) ;
2020-02-11 21:26:18 +01:00
/*
* Returning false , means messaging_dispatch_waiters ( )
* won ' t call messaging_filtered_read_done ( ) and
* our messaging_filtered_read_send ( ) stays alive
* and will get messages .
*/
return false ;
2002-01-03 03:53:41 +00:00
}
/**
* Register handler for MSG_REQ_POOL_USAGE
* */
2020-02-11 21:47:39 +01:00
void register_msg_pool_usage (
TALLOC_CTX * mem_ctx , struct messaging_context * msg_ctx )
2002-01-03 03:53:41 +00:00
{
2019-08-30 15:08:40 +02:00
struct tevent_req * req = NULL ;
req = messaging_filtered_read_send (
2020-02-11 21:47:39 +01:00
mem_ctx ,
2019-08-30 15:08:40 +02:00
messaging_tevent_context ( msg_ctx ) ,
msg_ctx ,
pool_usage_filter ,
NULL ) ;
if ( req = = NULL ) {
DBG_WARNING ( " messaging_filtered_read_send failed \n " ) ;
return ;
}
2002-01-03 03:53:41 +00:00
DEBUG ( 2 , ( " Registered MSG_REQ_POOL_USAGE \n " ) ) ;
2019-08-30 15:08:40 +02:00
}