Beispiel #1
0
BOOL init_pipe_handle_list(pipes_struct *p, char *pipe_name)
{
	pipes_struct *plist = get_first_internal_pipe();
	struct handle_list *hl = NULL;

	for (plist = get_first_internal_pipe(); plist; plist = get_next_internal_pipe(plist)) {
		if (strequal( plist->name, pipe_name) ||
				(is_samr_lsa_pipe(plist->name) && is_samr_lsa_pipe(pipe_name))) {
			if (!plist->pipe_handles) {
				pstring msg;
				slprintf(msg, sizeof(msg)-1, "init_pipe_handles: NULL pipe_handle pointer in pipe %s",
						pipe_name );
				smb_panic(msg);
			}
			hl = plist->pipe_handles;
			break;
		}
	}

	if (!hl) {
		/*
		 * No handle list for this pipe (first open of pipe).
		 * Create list.
		 */

		if ((hl = (struct handle_list *)malloc(sizeof(struct handle_list))) == NULL)
			return False;
		ZERO_STRUCTP(hl);

		DEBUG(10,("init_pipe_handles: created handle list for pipe %s\n", pipe_name ));
	}

	/*
	 * One more pipe is using this list.
	 */

	hl->pipe_ref_count++;

	/*
	 * Point this pipe at this list.
	 */

	p->pipe_handles = hl;

	DEBUG(10,("init_pipe_handles: pipe_handles ref count = %lu for pipe %s\n",
		  (unsigned long)p->pipe_handles->pipe_ref_count, pipe_name ));

	return True;
}
Beispiel #2
0
BOOL conn_idle_all(time_t t, int deadtime)
{
	pipes_struct *plist = NULL;
	BOOL allidle = True;
	connection_struct *conn, *next;

	for (conn=Connections;conn;conn=next) {
		next=conn->next;
		/* close dirptrs on connections that are idle */
		if ((t-conn->lastused) > DPTR_IDLE_TIMEOUT)
			dptr_idlecnum(conn);

		if (conn->num_files_open > 0 || 
		    (t-conn->lastused)<deadtime)
			allidle = False;
	}

	/*
	 * Check all pipes for any open handles. We cannot
	 * idle with a handle open.
	 */

	for (plist = get_first_internal_pipe(); plist; plist = get_next_internal_pipe(plist))
		if (plist->pipe_handles && plist->pipe_handles->count)
			allidle = False;
	
	return allidle;
}
Beispiel #3
0
bool init_pipe_handle_list(pipes_struct *p, const struct ndr_syntax_id *syntax)
{
    pipes_struct *plist;
    struct handle_list *hl;

    for (plist = get_first_internal_pipe();
            plist;
            plist = get_next_internal_pipe(plist)) {
        if (ndr_syntax_id_equal(syntax, &plist->syntax)) {
            break;
        }
        if (is_samr_lsa_pipe(&plist->syntax)
                && is_samr_lsa_pipe(syntax)) {
            /*
             * samr and lsa share a handle space (same process
             * under Windows?)
             */
            break;
        }
    }

    if (plist != NULL) {
        hl = plist->pipe_handles;
        if (hl == NULL) {
            return false;
        }
    } else {
        /*
         * First open, we have to create the handle list
         */
        hl = SMB_MALLOC_P(struct handle_list);
        if (hl == NULL) {
            return false;
        }
        ZERO_STRUCTP(hl);

        DEBUG(10,("init_pipe_handles: created handle list for "
                  "pipe %s\n",
                  get_pipe_name_from_syntax(talloc_tos(), syntax)));
    }

    /*
     * One more pipe is using this list.
     */

    hl->pipe_ref_count++;

    /*
     * Point this pipe at this list.
     */

    p->pipe_handles = hl;

    DEBUG(10,("init_pipe_handles: pipe_handles ref count = %lu for pipe %s\n",
              (unsigned long)p->pipe_handles->pipe_ref_count,
              get_pipe_name_from_syntax(talloc_tos(), syntax)));

    return True;
}