Ejemplo n.º 1
0
/****************************************************************************
  initialise policy handle states...
****************************************************************************/
void init_lsa_policy_hnd(void)
{
	bmap = bitmap_allocate(MAX_OPEN_POLS);
	if (!bmap) {
		exit_server("out of memory in init_lsa_policy_hnd\n");
	}
}
Ejemplo n.º 2
0
void init_rpc_pipe_hnd(void)
{
	bmap = bitmap_allocate(MAX_OPEN_PIPES);
	if (!bmap) {
		exit_server("out of memory in init_rpc_pipe_hnd");
	}
}
Ejemplo n.º 3
0
/* Allocates and returns a new 4096-bit bitmap that has 1-bit in positions in
 * the 'n_vlans' bits indicated in 'vlans' and 0-bits everywhere else.  Returns
 * a null pointer if there are no (valid) VLANs in 'vlans'. */
unsigned long *
vlan_bitmap_from_array(const int64_t *vlans, size_t n_vlans)
{
    unsigned long *b;

    if (!n_vlans) {
        return NULL;
    }

    b = bitmap_allocate(4096);
    if (!vlan_bitmap_from_array__(vlans, n_vlans, b)) {
        free(b);
        return NULL;
    }
    return b;
}
Ejemplo n.º 4
0
int main(void)
{
    bitmap_t bitmap = bitmap_allocate(6);
    if (bitmap == NULL)
        exit(EXIT_FAILURE);

    int i;
    for (i = 0; i < 3; i++) {
        bitmap_setbit(bitmap, i);
    }
    
    // Check up to 3 digits
    print_result(bitmap_alltrue(bitmap, 3));
    
    // Check up all digits
    print_result(bitmap_alltrue(bitmap, 0));

    bitmap_print(bitmap);
    
    bitmap_destroy(&bitmap);
    return (EXIT_SUCCESS);
}
Ejemplo n.º 5
0
	 */
	real_lim = set_maxfiles(request_max_open_files + MAX_OPEN_FUDGEFACTOR);

	real_max_open_files = real_lim - MAX_OPEN_FUDGEFACTOR;

	if (real_max_open_files + FILE_HANDLE_OFFSET + MAX_OPEN_PIPES > 65536)
		real_max_open_files = 65536 - FILE_HANDLE_OFFSET - MAX_OPEN_PIPES;

	if(real_max_open_files != request_max_open_files) {
		DEBUG(1,("file_init: Information only: requested %d \
open files, %d are available.\n", request_max_open_files, real_max_open_files));
	}

	SMB_ASSERT(real_max_open_files > 100);

	file_bmap = bitmap_allocate(real_max_open_files);
	
	if (!file_bmap) {
		exit_server("out of memory in file_init");
	}
}

/****************************************************************************
 Close files open by a specified vuid.
****************************************************************************/

void file_close_user(int vuid)
{
	files_struct *fsp, *next;

	for (fsp=Files;fsp;fsp=next) {
Ejemplo n.º 6
0
Archivo: conn.c Proyecto: jophxy/samba
/****************************************************************************
init the conn structures
****************************************************************************/
void conn_init(void)
{
	bmap = bitmap_allocate(MAX_CONNECTIONS);
}
Ejemplo n.º 7
0
/***************************************************** 
initialise structures
*******************************************************/
void smbw_init(void)
{
	extern BOOL in_client;
	static int initialised;
	static pstring servicesf = CONFIGFILE;
	extern FILE *dbf;
	char *p;
	int eno;
	pstring line;

	if (initialised) return;
	initialised = 1;

	eno = errno;

	smbw_busy++;

	DEBUGLEVEL = 0;
	AllowDebugChange = False;
	setup_logging("smbsh",True);

	dbf = stderr;

	if ((p=smbw_getshared("LOGFILE"))) {
		dbf = sys_fopen(p, "a");
	}

	smbw_file_bmap = bitmap_allocate(SMBW_MAX_OPEN);
	if (!smbw_file_bmap) {
		exit(1);
	}

	charset_initialise();

	in_client = True;

	load_interfaces();

	if ((p=smbw_getshared("SERVICESF"))) {
		pstrcpy(servicesf, p);
	}

	lp_load(servicesf,True,False,False);
	codepage_initialise(lp_client_code_page());

	get_myname(global_myname);

	if ((p=smbw_getshared("DEBUG"))) {
		DEBUGLEVEL = atoi(p);
	}

	if ((p=smbw_getshared("RESOLVE_ORDER"))) {
		lp_set_name_resolve_order(p);
	}

	if ((p=smbw_getshared("PREFIX"))) {
		slprintf(smbw_prefix,sizeof(fstring)-1, "/%s/", p);
		all_string_sub(smbw_prefix,"//", "/", 0);
		DEBUG(2,("SMBW_PREFIX is %s\n", smbw_prefix));
	}

	slprintf(line,sizeof(line)-1,"PWD_%d", (int)getpid());
	
	p = smbw_getshared(line);
	if (!p) {
		sys_getwd(smbw_cwd);
	}
	pstrcpy(smbw_cwd, p);
	DEBUG(4,("Initial cwd is %s\n", smbw_cwd));

	smbw_busy--;

	set_maxfiles(SMBW_MAX_OPEN);

	BlockSignals(True,SIGPIPE);

	errno = eno;
}
Ejemplo n.º 8
0
/****************************************************************************
  find first available connection slot, starting from a random position.
The randomisation stops problems with the server dieing and clients
thinking the server is still available.
****************************************************************************/
connection_struct *conn_new(void)
{
	TALLOC_CTX *mem_ctx;
	connection_struct *conn;
	int i;
        int find_offset = 1;

find_again:
	i = bitmap_find(bmap, find_offset);
	
	if (i == -1) {
                /* Expand the connections bitmap. */
                int             oldsz = bmap->n;
                int             newsz = bmap->n + BITMAP_BLOCK_SZ;
                struct bitmap * nbmap;

                if (newsz <= 0) {
                        /* Integer wrap. */
		        DEBUG(0,("ERROR! Out of connection structures\n"));
                        return NULL;
                }

		DEBUG(4,("resizing connections bitmap from %d to %d\n",
                        oldsz, newsz));

                nbmap = bitmap_allocate(newsz);
		if (!nbmap) {
			DEBUG(0,("ERROR! malloc fail.\n"));
			return NULL;
		}

                bitmap_copy(nbmap, bmap);
                bitmap_free(bmap);

                bmap = nbmap;
                find_offset = oldsz; /* Start next search in the new portion. */

                goto find_again;
	}

	if ((mem_ctx=talloc_init("connection_struct"))==NULL) {
		DEBUG(0,("talloc_init(connection_struct) failed!\n"));
		return NULL;
	}

	if ((conn=TALLOC_ZERO_P(mem_ctx, connection_struct))==NULL) {
		DEBUG(0,("talloc_zero() failed!\n"));
		return NULL;
	}
	conn->mem_ctx = mem_ctx;
	conn->cnum = i;

	bitmap_set(bmap, i);

	num_open++;

	string_set(&conn->user,"");
	string_set(&conn->dirpath,"");
	string_set(&conn->connectpath,"");
	string_set(&conn->origpath,"");
	
	DLIST_ADD(Connections, conn);

	return conn;
}
Ejemplo n.º 9
0
/****************************************************************************
init the conn structures
****************************************************************************/
void conn_init(void)
{
	bmap = bitmap_allocate(BITMAP_BLOCK_SZ);
}