* Separated create_socket() and the call to the protocol's open() function - open()
is not supposed to be called for accepted sockets, only for those created via a call the userland socket() function. * Renamed net_socket_module_info::socket() to open_socket() to make this distinction a bit clearer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19254 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -51,7 +51,7 @@ typedef struct net_socket {
|
|||||||
struct net_socket_module_info {
|
struct net_socket_module_info {
|
||||||
struct module_info info;
|
struct module_info info;
|
||||||
|
|
||||||
status_t (*socket)(int family, int type, int protocol, net_socket **_socket);
|
status_t (*open_socket)(int family, int type, int protocol, net_socket **_socket);
|
||||||
status_t (*close)(net_socket *socket);
|
status_t (*close)(net_socket *socket);
|
||||||
status_t (*free)(net_socket *socket);
|
status_t (*free)(net_socket *socket);
|
||||||
|
|
||||||
|
|||||||
@@ -409,7 +409,8 @@ net_stack_control(void *_cookie, uint32 op, void *data, size_t length)
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
return sSocket->socket(args.family, args.type, args.protocol, &cookie->socket);
|
return sSocket->open_socket(args.family, args.type,
|
||||||
|
args.protocol, &cookie->socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
case NET_STACK_GET_COOKIE:
|
case NET_STACK_GET_COOKIE:
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
void socket_delete(net_socket *socket);
|
void socket_delete(net_socket *socket);
|
||||||
|
|
||||||
|
|
||||||
status_t
|
static status_t
|
||||||
socket_create(int family, int type, int protocol, net_socket **_socket)
|
create_socket(int family, int type, int protocol, net_socket **_socket)
|
||||||
{
|
{
|
||||||
struct net_socket *socket = new (std::nothrow) net_socket;
|
struct net_socket *socket = new (std::nothrow) net_socket;
|
||||||
if (socket == NULL)
|
if (socket == NULL)
|
||||||
@@ -55,15 +55,9 @@ socket_create(int family, int type, int protocol, net_socket **_socket)
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
goto err2;
|
goto err2;
|
||||||
|
|
||||||
status = socket->first_info->open(socket->first_protocol);
|
|
||||||
if (status < B_OK)
|
|
||||||
goto err3;
|
|
||||||
|
|
||||||
*_socket = socket;
|
*_socket = socket;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
err3:
|
|
||||||
put_domain_protocols(socket);
|
|
||||||
err2:
|
err2:
|
||||||
benaphore_destroy(&socket->lock);
|
benaphore_destroy(&socket->lock);
|
||||||
err1:
|
err1:
|
||||||
@@ -72,6 +66,28 @@ err1:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
socket_open(int family, int type, int protocol, net_socket **_socket)
|
||||||
|
{
|
||||||
|
net_socket *socket;
|
||||||
|
status_t status = create_socket(family, type, protocol, &socket);
|
||||||
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
status = socket->first_info->open(socket->first_protocol);
|
||||||
|
if (status < B_OK) {
|
||||||
|
socket_delete(socket);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
*_socket = socket;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
socket_close(net_socket *socket)
|
socket_close(net_socket *socket)
|
||||||
{
|
{
|
||||||
@@ -200,7 +216,7 @@ socket_spawn_pending(net_socket *parent, net_socket **_socket)
|
|||||||
return ENOBUFS;
|
return ENOBUFS;
|
||||||
|
|
||||||
net_socket *socket;
|
net_socket *socket;
|
||||||
status_t status = socket_create(parent->family, parent->type, parent->protocol, &socket);
|
status_t status = create_socket(parent->family, parent->type, parent->protocol, &socket);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@@ -797,7 +813,7 @@ net_socket_module_info gNetSocketModule = {
|
|||||||
0,
|
0,
|
||||||
socket_std_ops
|
socket_std_ops
|
||||||
},
|
},
|
||||||
socket_create,
|
socket_open,
|
||||||
socket_close,
|
socket_close,
|
||||||
socket_free,
|
socket_free,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user