예제 #1
0
static int
dump_socket(int argc, char** argv)
{
	if (argc < 2) {
		kprintf("usage: %s [address]\n", argv[0]);
		return 0;
	}

	net_socket_private* socket = (net_socket_private*)parse_expression(argv[1]);

	kprintf("SOCKET %p\n", socket);
	kprintf("  family.type.protocol: %d.%d.%d\n",
		socket->family, socket->type, socket->protocol);
	WeakReference<net_socket_private> parent = socket->parent;
	kprintf("  parent:               %p (%p)\n", parent.Get(), socket->parent);
	kprintf("  first protocol:       %p\n", socket->first_protocol);
	kprintf("  first module_info:    %p\n", socket->first_info);
	kprintf("  options:              %x\n", socket->options);
	kprintf("  linger:               %d\n", socket->linger);
	kprintf("  bound to device:      %d\n", socket->bound_to_device);
	kprintf("  owner:                %ld\n", socket->owner);
	kprintf("  max backlog:          %ld\n", socket->max_backlog);
	kprintf("  is connected:         %d\n", socket->is_connected);
	kprintf("  child_count:          %lu\n", socket->child_count);

	if (socket->child_count == 0)
		return 0;

	kprintf("    pending children:\n");
	SocketList::Iterator iterator = socket->pending_children.GetIterator();
	while (net_socket_private* child = iterator.Next()) {
		print_socket_line(child, "      ");
	}

	kprintf("    connected children:\n");
	iterator = socket->connected_children.GetIterator();
	while (net_socket_private* child = iterator.Next()) {
		print_socket_line(child, "      ");
	}

	return 0;
}
예제 #2
0
/*!	The socket has been aborted. Steals the parent's reference, and releases
	it.
*/
status_t
socket_aborted(net_socket* _socket)
{
	net_socket_private* socket = (net_socket_private*)_socket;

	WeakReference<net_socket_private> parent = socket->parent;
	if (parent.Get() == NULL)
		return B_BAD_VALUE;

	MutexLocker _(parent->lock);

	if (socket->is_connected)
		parent->connected_children.Remove(socket);
	else
		parent->pending_children.Remove(socket);

	parent->child_count--;
	socket->RemoveFromParent();

	return B_OK;
}
예제 #3
0
/*!	The socket has been connected. It will be moved to the connected queue
	of its parent socket.
*/
status_t
socket_connected(net_socket* _socket)
{
	net_socket_private* socket = (net_socket_private*)_socket;

	WeakReference<net_socket_private> parent = socket->parent;
	if (parent.Get() == NULL)
		return B_BAD_VALUE;

	MutexLocker _(parent->lock);

	parent->pending_children.Remove(socket);
	parent->connected_children.Add(socket);
	socket->is_connected = true;

	// notify parent
	if (parent->select_pool)
		notify_select_event_pool(parent->select_pool, B_SELECT_READ);

	return B_OK;
}