2002-06-15 15:15:31 +04:00
/*
Unix SMB / CIFS implementation .
Authenticate against a remote domain
Copyright ( C ) Andrew Tridgell 1992 - 2002
Copyright ( C ) Andrew Bartlett 2002
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-06-15 15:15:31 +04:00
( at your option ) any later version .
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 .
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-06-15 15:15:31 +04:00
*/
# include "includes.h"
/* For reasons known only to MS, many of their NT/Win2k versions
need serialised access only . Two connections at the same time
may ( in certain situations ) cause connections to be reset ,
or access to be denied .
This locking allows smbd ' s mutlithread architecture to look
like the single - connection that NT makes . */
static char * mutex_server_name ;
2007-10-19 04:40:25 +04:00
bool grab_server_mutex ( const char * name )
2002-06-15 15:15:31 +04:00
{
2004-12-07 21:25:53 +03:00
mutex_server_name = SMB_STRDUP ( name ) ;
2002-06-15 15:15:31 +04:00
if ( ! mutex_server_name ) {
DEBUG ( 0 , ( " grab_server_mutex: malloc failed for %s \n " , name ) ) ;
return False ;
}
2003-03-18 02:06:12 +03:00
if ( ! secrets_named_mutex ( mutex_server_name , 10 ) ) {
2002-06-15 15:15:31 +04:00
DEBUG ( 10 , ( " grab_server_mutex: failed for %s \n " , name ) ) ;
SAFE_FREE ( mutex_server_name ) ;
return False ;
}
return True ;
}
void release_server_mutex ( void )
{
if ( mutex_server_name ) {
2003-03-18 02:06:12 +03:00
secrets_named_mutex_release ( mutex_server_name ) ;
2002-06-15 15:15:31 +04:00
SAFE_FREE ( mutex_server_name ) ;
}
}