2002-01-03 06:53:41 +03:00
/*
2002-01-30 09:08:46 +03:00
samba - - Unix SMB / CIFS implementation .
2002-01-03 08:26:57 +03:00
Copyright ( C ) 2001 , 2002 by Martin Pool
2010-01-17 15:52:53 +03:00
2002-01-03 06:53:41 +03: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 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2002-01-03 06:53:41 +03:00
( at your option ) any later version .
2010-01-17 15:52:53 +03:00
2002-01-03 06:53:41 +03: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 15:52:53 +03:00
2002-01-03 06:53:41 +03:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2002-01-03 06:53:41 +03:00
*/
# include "includes.h"
2011-03-24 17:31:06 +03:00
# include "messages.h"
2019-08-30 16:08:40 +03:00
# include "lib/util/talloc_report_printf.h"
2002-01-03 06:53:41 +03:00
2019-08-30 16:08:40 +03:00
static bool pool_usage_filter ( struct messaging_rec * rec , void * private_data )
2019-03-29 14:44:50 +03:00
{
2020-02-11 23:26:18 +03:00
FILE * f = NULL ;
int fd ;
2019-08-30 16:08:40 +03:00
if ( rec - > msg_type ! = MSG_REQ_POOL_USAGE ) {
return false ;
}
DBG_DEBUG ( " Got MSG_REQ_POOL_USAGE \n " ) ;
2019-03-29 14:44:50 +03:00
2019-08-30 16:08:40 +03:00
if ( rec - > num_fds ! = 1 ) {
DBG_DEBUG ( " Got % " PRIu8 " fds, expected one \n " , rec - > num_fds ) ;
return false ;
}
2020-02-11 23:26:18 +03: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 14:30:45 +03:00
}
2020-02-11 23:26:18 +03:00
f = fdopen ( fd , " w " ) ;
2019-08-30 16:08:40 +03:00
if ( f = = NULL ) {
DBG_DEBUG ( " fdopen failed: %s \n " , strerror ( errno ) ) ;
2020-02-11 23:26:18 +03:00
close ( fd ) ;
return false ;
2019-03-29 14:44:50 +03:00
}
2019-08-30 16:08:40 +03:00
talloc_full_report_printf ( NULL , f ) ;
fclose ( f ) ;
2020-02-11 23:26:18 +03: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 06:53:41 +03:00
}
/**
* Register handler for MSG_REQ_POOL_USAGE
* */
2020-02-11 23:47:39 +03:00
void register_msg_pool_usage (
TALLOC_CTX * mem_ctx , struct messaging_context * msg_ctx )
2002-01-03 06:53:41 +03:00
{
2019-08-30 16:08:40 +03:00
struct tevent_req * req = NULL ;
req = messaging_filtered_read_send (
2020-02-11 23:47:39 +03:00
mem_ctx ,
2019-08-30 16:08:40 +03: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 06:53:41 +03:00
DEBUG ( 2 , ( " Registered MSG_REQ_POOL_USAGE \n " ) ) ;
2019-08-30 16:08:40 +03:00
}