Ejemplo n.º 1
0
status_t
BTeamDebugger::Install(team_id team)
{
	Uninstall();

	// create a debugger port
	char name[B_OS_NAME_LENGTH];
	snprintf(name, sizeof(name), "debugger for team %" B_PRId32, team);
	fDebuggerPort = create_port(100, name);
	if (fDebuggerPort < 0)
		return fDebuggerPort;

	port_id nubPort = install_team_debugger(team, fDebuggerPort);
	if (nubPort < 0) {
		delete_port(fDebuggerPort);
		fDebuggerPort = -1;
		return nubPort;
	}

	status_t error = BDebugContext::Init(team, nubPort);
	if (error != B_OK) {
		remove_team_debugger(team);
		delete_port(fDebuggerPort);
		fDebuggerPort = -1;
		return error;
	}

	return B_OK;
}
Ejemplo n.º 2
0
static void
port_status_updated( void *user_data, const topology_port_status *status ) {
  assert( user_data != NULL );
  assert( status != NULL );

  broadcast_helper *broadcast_helper = user_data;

  debug( "Port status updated: dpid:%#" PRIx64 ", port:%u, %s, %s",
         status->dpid, status->port_no,
         ( status->status == TD_PORT_UP ? "up" : "down" ),
         ( status->external == TD_PORT_EXTERNAL ? "external" : "internal or inactive" ) );

  if ( status->port_no > OFPP_MAX && status->port_no != OFPP_LOCAL ) {
    warn( "Ignore this update ( port = %u )", status->port_no );
    return;
  }

  port_info *p = lookup_port( broadcast_helper->switches, status->dpid, status->port_no );

  if ( status->status == TD_PORT_UP ) {
    if ( p != NULL ) {
      update_port( p, status->external );
      return;
    }
    add_port( &broadcast_helper->switches, status->dpid, status->port_no, status->external );
  }
  else {
    if ( p == NULL ) {
      debug( "Ignore this update (not found nor already deleted)" );
      return;
    }
    delete_port( &broadcast_helper->switches, p );
  }
}
Ejemplo n.º 3
0
TimeSourceObject::TimeSourceObject(const media_node& node)
	:
	BMediaNode("some timesource object", node.node, node.kind),
	BTimeSource(node.node)
{
	TRACE("TimeSourceObject::TimeSourceObject enter, id = %ld\n", node.node);
	if (fControlPort > 0)
		delete_port(fControlPort);

	// We use the control port of the real time source object.
	// this way, all messages are send to the real time source,
	// and this shadow object won't receive any.
	fControlPort = node.port;

	ASSERT(fNodeID == node.node);
	ASSERT(fKinds == node.kind);

	if (node.node == NODE_SYSTEM_TIMESOURCE_ID) {
		strcpy(fName, "System clock");
		fIsRealtime = true;
	} else {
		live_node_info liveNodeInfo;
		if (BMediaRoster::Roster()->GetLiveNodeInfo(node, &liveNodeInfo)
				== B_OK)
			strlcpy(fName, liveNodeInfo.name, B_MEDIA_NAME_LENGTH);
		else
			snprintf(fName, B_MEDIA_NAME_LENGTH, "timesource %ld", node.node);
	}

	AddNodeKind(NODE_KIND_SHADOW_TIMESOURCE);
	AddNodeKind(NODE_KIND_NO_REFCOUNTING);

	TRACE("TimeSourceObject::TimeSourceObject leave, node id %ld\n", fNodeID);
}
Ejemplo n.º 4
0
extern "C" int32
tracker_loop(void *data)
{
	// create global messaging port
	
	gTrackerPort = create_port(128, "fsh tracker port");
	if (gTrackerPort < FS_OK)
		return gTrackerPort;

	while (true) {
		update_message message;
		int32 code;
		status_t status = read_port(gTrackerPort, &code, &message, sizeof(message));
		if (status < FS_OK)
			continue;

		if (code == FSH_KILL_TRACKER)
			break;

		if (code == FSH_NOTIFY_LISTENER) {
			printf("tracker: notify listener received\n");
			if (message.op != B_ATTR_CHANGED && message.op != B_DEVICE_UNMOUNTED)
				tracker_query_file(message.device, message.parentNode, message.name);
		} else if (code == B_QUERY_UPDATE) {
			printf("tracker: query update received\n");
			tracker_query_file(message.device, message.parentNode, message.name);
		} else {
			printf("tracker: unknown code received: 0x%lx\n", code);
		}
	}

	delete_port(gTrackerPort);
	return FS_OK;
}
Ejemplo n.º 5
0
// destructor
ColorSlider::~ColorSlider()
{
	if (fUpdatePort)
		delete_port(fUpdatePort);
	if (fUpdateThread)
		kill_thread(fUpdateThread);

	delete fBgBitmap;	
}
Ejemplo n.º 6
0
// destructor
ColorField::~ColorField()
{
	if (fUpdatePort >= B_OK)
		delete_port(fUpdatePort);
	if (fUpdateThread >= B_OK)
		kill_thread(fUpdateThread);

	delete fBgBitmap[0];
	delete fBgBitmap[1];
}
Ejemplo n.º 7
0
void
Job::_DeletePorts()
{
	PortMap::const_iterator iterator = Ports().begin();
	for (; iterator != Ports().end(); iterator++) {
		port_id port = iterator->second.GetInt32("port", -1);
		if (port >= 0)
			delete_port(port);
	}
}
Ejemplo n.º 8
0
bool
SyslogDaemon::QuitRequested()
{
	delete_port(fPort);

	int32 returnCode;
	wait_for_thread(fDaemon, &returnCode);

	return true;
}
Ejemplo n.º 9
0
static void
haiku_cleanup_team_debug_info()
{
	destroy_debug_context(&sTeamDebugInfo.context);
	delete_port(sTeamDebugInfo.debugger_port);
	sTeamDebugInfo.debugger_port = -1;
	sTeamDebugInfo.team = -1;

	haiku_cleanup_thread_list(&sTeamDebugInfo);
	haiku_cleanup_image_list(&sTeamDebugInfo);
}
Ejemplo n.º 10
0
void
DebuggerInterface::Close(bool killTeam)
{
	if (killTeam)
		kill_team(fTeamID);
	else if (fNubPort >= 0)
		remove_team_debugger(fTeamID);

	if (fDebuggerPort >= 0)
		delete_port(fDebuggerPort);
}
Ejemplo n.º 11
0
BMidiLocalConsumer::~BMidiLocalConsumer()
{
	TRACE(("BMidiLocalConsumer::~BMidiLocalConsumer"))

	BMidiRoster::MidiRoster()->DeleteLocal(this);

	delete_port(fPort);

	status_t result;
	wait_for_thread(fThread, &result);
}
Ejemplo n.º 12
0
static void
shutdown_connection(connection_cookie *cookie)
{
	printf("free cookie: %p\n",cookie);
	kill_thread(cookie->runner);

	delete_port(cookie->localPort);
	delete_sem(cookie->commandSemaphore);
	delete_area(cookie->area);

	free(cookie);
}
Ejemplo n.º 13
0
status_t
HaikuRTSPClient::WaitForInit(bigtime_t timeout)
{
	status_t status = B_ERROR;
	if (read_port_etc(fInitPort, NULL, &status,
			sizeof(status), B_RELATIVE_TIMEOUT, timeout) < 0) {
		return B_ERROR;
	}

	close_port(fInitPort);
	delete_port(fInitPort);
	fInitPort = -1;
	return status;
}
Ejemplo n.º 14
0
MediaAddonServer::~MediaAddonServer()
{
	CALLED();

	delete_port(fControlPort);
	wait_for_thread(fControlThread, NULL);

	// unregister all media add-ons
	FileMap::iterator iterator = fFileMap.begin();
	for (; iterator != fFileMap.end(); iterator++)
		gDormantNodeManager->UnregisterAddOn(iterator->second);

	// TODO: unregister system time source
}
Ejemplo n.º 15
0
ServerApp::~ServerApp()
{
    TRACE("ServerApp::~ServerApp()\n");

    delete_port(fControlPort);
    wait_for_thread(fControlThread, NULL);

    delete gAddOnManager;
    delete gNotificationManager;
    delete gBufferManager;
    delete gAppManager;
    delete gNodeManager;
    delete gMediaFilesManager;
    delete gFormatManager;
}
Ejemplo n.º 16
0
port_id
Job::_CreateAndTransferPort(const char* name, int32 capacity)
{
    port_id port = create_port(B_LOOPER_PORT_DEFAULT_CAPACITY, Name());
    if (port < 0)
        return port;

    status_t status = set_port_owner(port, fTeam);
    if (status != B_OK) {
        delete_port(port);
        return status;
    }

    return port;
}
Ejemplo n.º 17
0
ServerApp::~ServerApp()
{
	TRACE("ServerApp::~ServerApp()\n");
	delete gAddOnManager;
	delete gNotificationManager;
	delete gBufferManager;
	delete gAppManager;
	delete gNodeManager;
	delete gMMediaFilesManager;
	delete gFormatManager;
	delete fLocker;
	delete_port(control_port);
	status_t err;
	wait_for_thread(control_thread,&err);
}
Ejemplo n.º 18
0
ServerApp::~ServerApp()
{
	TRACE("ServerApp::~ServerApp()\n");

	delete_port(fControlPort);
	wait_for_thread(fControlThread, NULL);

	if (be_roster->StopWatching(BMessenger(this, this)) != B_OK)
		TRACE("ServerApp: Can't unregister roster notifications.");

	delete gNotificationManager;
	delete gBufferManager;
	delete gAppManager;
	delete gNodeManager;
	delete gMediaFilesManager;
}
Ejemplo n.º 19
0
status_t
BTeamDebugger::Uninstall()
{
	if (Team() < 0)
		return B_BAD_VALUE;

	remove_team_debugger(Team());

	delete_port(fDebuggerPort);

	BDebugContext::Uninit();

	fDebuggerPort = -1;

	return B_OK;
}
Ejemplo n.º 20
0
// destructor
AuthenticationServer::~AuthenticationServer()
{
	fTerminating = true;
	// terminate the request thread
	if (fRequestPort >= 0)
		delete_port(fRequestPort);
	if (fRequestThread >= 0) {
		int32 result;
		wait_for_thread(fRequestPort, &result);
	}
	// delete the server entries
	for (ServerEntryMap::Iterator it = fServerEntries->GetIterator();
		 it.HasNext();) {
		delete it.Next().value;
	}
}
Ejemplo n.º 21
0
TVideoPreviewView::~TVideoPreviewView()
{
	mControlQuit = true;
	mDisplayQuit = true;

	write_port(mPort, 0x60000000, NULL, 0);

	status_t status;
	wait_for_thread(mThread, &status);
	if (vThread != 0)
		wait_for_thread(vThread, &status);

	vThread = 0;
	mThread = 0;

	delete_port(mPort);
}
Ejemplo n.º 22
0
void
LocalDebuggerInterface::Close(bool killTeam)
{
	if (killTeam)
		kill_team(fTeamID);
	else if (fNubPort >= 0)
		remove_team_debugger(fTeamID);

	if (fDebuggerPort >= 0) {
		__stop_watching_system(fTeamID, B_WATCH_SYSTEM_THREAD_PROPERTIES,
			fDebuggerPort, 0);
		delete_port(fDebuggerPort);
	}

	fNubPort = -1;
	fDebuggerPort = -1;
}
Ejemplo n.º 23
0
static void
port_status_updated( void *user_data, const topology_port_status *status ) {
  assert( user_data != NULL );
  assert( status != NULL );

  sliceable_switch *sliceable_switch = user_data;
  if ( sliceable_switch->second_stage_down == false ) {
    return;
  }

  debug( "Port status updated: dpid:%#" PRIx64 ", port:%u(%s), %s, %s",
         status->dpid, status->port_no, status->name,
         ( status->status == TD_PORT_UP ? "up" : "down" ),
         ( status->external == TD_PORT_EXTERNAL ? "external" : "internal or inactive" ) );

  if ( status->port_no > OFPP_MAX && status->port_no != OFPP_LOCAL ) {
    warn( "Ignore this update ( port = %u )", status->port_no );
    return;
  }

  port_info *p = lookup_port( sliceable_switch->switches, status->dpid, status->port_no );

  delete_fdb_entries( sliceable_switch->fdb, status->dpid, status->port_no );

  if ( status->status == TD_PORT_UP ) {
    if ( p != NULL ) {
      update_port( p, status->external );
      return;
    }
    add_port( &sliceable_switch->switches, status->dpid, status->port_no, status->name, status->external );
  }
  else {
    if ( p == NULL ) {
      debug( "Ignore this update (not found nor already deleted)" );
      return;
    }
    delete_port( &sliceable_switch->switches, p );
    struct ofp_match match;
    memset( &match, 0, sizeof( struct ofp_match ) );
    match.wildcards = OFPFW_ALL;
    match.wildcards &= ~OFPFW_IN_PORT;
    match.in_port = status->port_no;
    teardown_path_by_match( match );
  }
}
Ejemplo n.º 24
0
ServerApp::~ServerApp()
{
	TRACE("ServerApp::~ServerApp()\n");

	delete_port(fControlPort);
	wait_for_thread(fControlThread, NULL);

	delete gNotificationManager;
	delete gBufferManager;
	delete gAppManager;
	delete gNodeManager;
	delete gMediaFilesManager;

	BMediaRoster* roster = BMediaRoster::CurrentRoster();
	if (roster->StopWatching(BMessenger(this, this),
			B_MEDIA_SERVER_QUIT) != B_OK) {
		TRACE("ServerApp: can't unwatch for B_MEDIA_SERVER_QUIT");
	}
}
Ejemplo n.º 25
0
status_t
init_userland_ipc(void)
{
	gStackPort = create_port(CONNECTION_QUEUE_LENGTH, NET_STACK_PORTNAME);
	if (gStackPort < B_OK)
		return gStackPort;

	gConnectionOpener = spawn_thread(connection_opener, "connection opener", B_NORMAL_PRIORITY, NULL);
	if (resume_thread(gConnectionOpener) < B_OK) {
		delete_port(gStackPort);
		if (gConnectionOpener >= B_OK) {
			kill_thread(gConnectionOpener);
			return B_BAD_THREAD_STATE;
		}
		return gConnectionOpener;
	}

	return B_OK;
}
Ejemplo n.º 26
0
/*
 * msg_disconnect()
 *	Shut down a message queue
 *
 * Works for both server and client sides, with somewhat different
 * effects.
 */
int
msg_disconnect(port_t arg_port)
{
	struct proc *p = curthread->t_proc;
	struct portref *pr;
	struct port *port;

	if (arg_port >= PROCOPENS) {
		/*
		 * Get port, and delete from proc list.  After this we are
		 * the last server thread to access the port as a server.
		 */
		port = delete_port(p, arg_port);
		if (!port) {
			return(-1);
		}

		/*
		 * Delete all current clients
		 */
		return(shut_server(port));
	} else {
#ifdef PROC_DEBUG
		/*
		 * Prevent miscreant from shutting our debug session
		 */
		if (p->p_dbg.pd_name && (arg_port == p->p_dbg.pd_port)) {
			return(err(EINVAL));
		}
#endif
		/*
		 * Get the portref, or error.  The slot is now deleted from
		 * the "open ports" list in the proc.
		 */
		pr = delete_portref(p, arg_port, 0);
		if (!pr) {
			return(-1);
		}
		shut_client(pr, 0);
		return(0);
	}
}
Ejemplo n.º 27
0
status_t
_user_delete_port(port_id id)
{
	return delete_port(id);
}
Ejemplo n.º 28
0
void
shutdown_userland_ipc(void)
{
	delete_port(gStackPort);
	kill_thread(gConnectionOpener);
}
Ejemplo n.º 29
0
static status_t
init_connection(net_connection *connection, connection_cookie **_cookie)
{
	connection_cookie *cookie;
	net_command *commands;

	cookie = (connection_cookie *) malloc(sizeof(connection_cookie));
	if (cookie == NULL) {
		fprintf(stderr, "couldn't allocate memory for cookie.\n");
		return B_NO_MEMORY;
	}

	connection->area = create_area("net connection", (void *) &commands, B_ANY_ADDRESS,
			CONNECTION_BUFFER_SIZE + CONNECTION_COMMAND_SIZE,
			B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
	if (connection->area < B_OK) {
		fprintf(stderr, "couldn't create area: %s.\n", strerror(connection->area));
		free(cookie);
		return connection->area;
	}
	memset(commands,0,NUM_COMMANDS * sizeof(net_command));

	connection->port = create_port(CONNECTION_QUEUE_LENGTH, "net stack connection");
	if (connection->port < B_OK) {
		fprintf(stderr, "couldn't create port: %s.\n", strerror(connection->port));
		delete_area(connection->area);
		free(cookie);
		return connection->port;
	}
	
	connection->commandSemaphore = create_sem(0, "net command queue");
	if (connection->commandSemaphore < B_OK) {
		fprintf(stderr, "couldn't create semaphore: %s.\n", strerror(connection->commandSemaphore));
		delete_area(connection->area);
		delete_port(connection->port);
		free(cookie);
		return connection->commandSemaphore;
	}

	cookie->runner = spawn_thread(connection_runner, "connection runner", B_NORMAL_PRIORITY, cookie);
	if (cookie->runner < B_OK) {
		fprintf(stderr, "couldn't create thread: %s.\n", strerror(cookie->runner));
		delete_sem(connection->commandSemaphore);
		delete_area(connection->area);
		delete_port(connection->port);
		free(cookie);
		return B_ERROR;
	}

	connection->socket_thread = cookie->runner;

	connection->numCommands = NUM_COMMANDS;
	connection->bufferSize = CONNECTION_BUFFER_SIZE;

	// setup connection cookie
	cookie->area = connection->area;
	cookie->commands = commands;
	cookie->buffer = (uint8 *)commands + CONNECTION_COMMAND_SIZE;
	cookie->commandSemaphore = connection->commandSemaphore;
	cookie->localPort = connection->port;
	cookie->openFlags = 0;
	
	cookie->socket_event_port = -1;
	cookie->notify_cookie = NULL;

	resume_thread(cookie->runner);

	*_cookie = cookie;
	return B_OK;
}
Ejemplo n.º 30
0
BAppServerLink::~BAppServerLink()
{
	delete_port(receiver);
	if (be_app)
		be_app->Unlock();
}