* Now gets the net_socket module in init_stack() to make sure it's initialized
as long as the stack is loaded. * This fixes another regression from moving the socket API into the kernel. * Thanks to Romain for reporting this! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30198 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1604,6 +1604,7 @@ socket_std_ops(int32 op, ...)
|
||||
return B_OK;
|
||||
}
|
||||
case B_MODULE_UNINIT:
|
||||
ASSERT(sSocketList.IsEmpty());
|
||||
mutex_destroy(&sSocketLock);
|
||||
|
||||
#ifdef ADD_DEBUGGER_COMMANDS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -338,7 +338,8 @@ chain::Lookup(hash_table *chains, int family, int type, int protocol)
|
||||
|
||||
|
||||
/*static*/ struct chain*
|
||||
chain::Add(hash_table *chains, int family, int type, int protocol, va_list modules)
|
||||
chain::Add(hash_table* chains, int family, int type, int protocol,
|
||||
va_list modules)
|
||||
{
|
||||
struct chain* chain = new (std::nothrow) ::chain(family, type, protocol);
|
||||
if (chain == NULL)
|
||||
@@ -431,7 +432,7 @@ get_domain_protocols(net_socket *socket)
|
||||
struct chain* chain;
|
||||
|
||||
{
|
||||
MutexLocker locker(&sChainLock);
|
||||
MutexLocker _(sChainLock);
|
||||
|
||||
chain = chain::Lookup(sProtocolChains, socket->family, socket->type,
|
||||
socket->type == SOCK_RAW ? 0 : socket->protocol);
|
||||
@@ -446,7 +447,7 @@ get_domain_protocols(net_socket *socket)
|
||||
// create net_protocol objects for the protocols in the chain
|
||||
|
||||
status_t status = chain->Acquire();
|
||||
if (status < B_OK)
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
net_protocol* last = NULL;
|
||||
@@ -484,7 +485,7 @@ put_domain_protocols(net_socket *socket)
|
||||
struct chain* chain;
|
||||
|
||||
{
|
||||
MutexLocker locker(&sChainLock);
|
||||
MutexLocker _(sChainLock);
|
||||
|
||||
chain = chain::Lookup(sProtocolChains, socket->family, socket->type,
|
||||
socket->protocol);
|
||||
@@ -521,7 +522,7 @@ get_domain_datalink_protocols(net_interface *_interface)
|
||||
struct chain* chain;
|
||||
|
||||
{
|
||||
MutexLocker locker(&sChainLock);
|
||||
MutexLocker _(sChainLock);
|
||||
|
||||
chain = chain::Lookup(sDatalinkProtocolChains, interface->domain->family,
|
||||
interface->device_interface->device->type, 0);
|
||||
@@ -539,8 +540,8 @@ get_domain_datalink_protocols(net_interface *_interface)
|
||||
|
||||
for (int32 i = 0; chain->infos[i] != NULL; i++) {
|
||||
net_datalink_protocol* protocol;
|
||||
status_t status = ((net_datalink_protocol_module_info *)chain->infos[i])->init_protocol(
|
||||
interface, &protocol);
|
||||
status_t status = ((net_datalink_protocol_module_info*)
|
||||
chain->infos[i])->init_protocol(interface, &protocol);
|
||||
if (status < B_OK) {
|
||||
// free protocols we already initialized
|
||||
uninit_domain_datalink_protocols(interface);
|
||||
@@ -572,7 +573,7 @@ put_domain_datalink_protocols(net_interface *_interface)
|
||||
struct chain* chain;
|
||||
|
||||
{
|
||||
MutexLocker locker(&sChainLock);
|
||||
MutexLocker _(sChainLock);
|
||||
|
||||
chain = chain::Lookup(sDatalinkProtocolChains, interface->domain->family,
|
||||
interface->device_interface->device->type, 0);
|
||||
@@ -593,9 +594,11 @@ get_domain_receiving_protocol(net_domain *_domain, uint32 type,
|
||||
struct net_domain_private* domain = (net_domain_private*)_domain;
|
||||
struct chain* chain;
|
||||
|
||||
TRACE(("get_domain_receiving_protocol(family %d, type %lu)\n", domain->family, type));
|
||||
TRACE(("get_domain_receiving_protocol(family %d, type %lu)\n",
|
||||
domain->family, type));
|
||||
|
||||
{
|
||||
MutexLocker locker(&sChainLock);
|
||||
MutexLocker _(sChainLock);
|
||||
|
||||
chain = chain::Lookup(sReceivingProtocolChains, domain->family,
|
||||
type, 0);
|
||||
@@ -604,7 +607,7 @@ get_domain_receiving_protocol(net_domain *_domain, uint32 type,
|
||||
}
|
||||
|
||||
status_t status = chain->Acquire();
|
||||
if (status < B_OK)
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
*_module = (net_protocol_module_info*)chain->infos[0];
|
||||
@@ -619,7 +622,7 @@ put_domain_receiving_protocol(net_domain *_domain, uint32 type)
|
||||
struct chain* chain;
|
||||
|
||||
{
|
||||
MutexLocker locker(&sChainLock);
|
||||
MutexLocker _(sChainLock);
|
||||
|
||||
chain = chain::Lookup(sReceivingProtocolChains, domain->family,
|
||||
type, 0);
|
||||
@@ -666,7 +669,8 @@ register_domain_datalink_protocols(int family, int type, ...)
|
||||
TRACE(("register_domain_datalink_protocol(%d.%d)\n", family, type));
|
||||
MutexLocker locker(&sChainLock);
|
||||
|
||||
struct chain *chain = chain::Lookup(sDatalinkProtocolChains, family, type, 0);
|
||||
struct chain* chain
|
||||
= chain::Lookup(sDatalinkProtocolChains, family, type, 0);
|
||||
if (chain != NULL)
|
||||
return B_OK;
|
||||
|
||||
@@ -680,8 +684,8 @@ register_domain_datalink_protocols(int family, int type, ...)
|
||||
if (chain == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// Add datalink interface protocol as the last protocol in the chain; it's name
|
||||
// stays unset, so that it won't be part of the release/acquire process.
|
||||
// Add datalink interface protocol as the last protocol in the chain; it's
|
||||
// name stays unset, so that it won't be part of the release/acquire process.
|
||||
|
||||
uint32 count = 0;
|
||||
while (chain->modules[count] != NULL) {
|
||||
@@ -699,13 +703,15 @@ register_domain_receiving_protocol(int family, int type, const char *moduleName)
|
||||
TRACE(("register_domain_receiving_protocol(%d.%d, %s)\n", family, type,
|
||||
moduleName));
|
||||
|
||||
MutexLocker locker(&sChainLock);
|
||||
MutexLocker _(sChainLock);
|
||||
|
||||
struct chain *chain = chain::Lookup(sReceivingProtocolChains, family, type, 0);
|
||||
struct chain* chain
|
||||
= chain::Lookup(sReceivingProtocolChains, family, type, 0);
|
||||
if (chain != NULL)
|
||||
return B_OK;
|
||||
|
||||
chain = chain::Add(sReceivingProtocolChains, family, type, 0, moduleName, NULL);
|
||||
chain = chain::Add(sReceivingProtocolChains, family, type, 0, moduleName,
|
||||
NULL);
|
||||
if (chain == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@@ -742,15 +748,15 @@ status_t
|
||||
init_stack()
|
||||
{
|
||||
status_t status = init_domains();
|
||||
if (status < B_OK)
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
status = init_interfaces();
|
||||
if (status < B_OK)
|
||||
if (status != B_OK)
|
||||
goto err1;
|
||||
|
||||
status = init_timers();
|
||||
if (status < B_OK)
|
||||
if (status != B_OK)
|
||||
goto err2;
|
||||
|
||||
status = init_notifications();
|
||||
@@ -761,6 +767,11 @@ init_stack()
|
||||
strerror(status));
|
||||
}
|
||||
|
||||
module_info* dummy;
|
||||
status = get_module(NET_SOCKET_MODULE_NAME, &dummy);
|
||||
if (status != B_OK)
|
||||
goto err3;
|
||||
|
||||
mutex_init(&sChainLock, "net chains");
|
||||
mutex_init(&sInitializeChainLock, "net intialize chains");
|
||||
|
||||
@@ -818,6 +829,7 @@ err6:
|
||||
err5:
|
||||
mutex_destroy(&sInitializeChainLock);
|
||||
mutex_destroy(&sChainLock);
|
||||
err3:
|
||||
uninit_timers();
|
||||
err2:
|
||||
uninit_interfaces();
|
||||
@@ -832,6 +844,7 @@ uninit_stack()
|
||||
{
|
||||
TRACE(("Unloading network stack\n"));
|
||||
|
||||
put_module(NET_SOCKET_MODULE_NAME);
|
||||
uninit_timers();
|
||||
uninit_interfaces();
|
||||
uninit_domains();
|
||||
@@ -848,7 +861,8 @@ uninit_stack()
|
||||
|
||||
uint32 cookie = 0;
|
||||
while (true) {
|
||||
struct family *family = (struct family *)hash_remove_first(sFamilies, &cookie);
|
||||
struct family* family = (struct family*)hash_remove_first(sFamilies,
|
||||
&cookie);
|
||||
if (family == NULL)
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user