* 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:
@@ -25,8 +25,8 @@
|
||||
void socket_delete(net_socket *socket);
|
||||
|
||||
|
||||
status_t
|
||||
socket_create(int family, int type, int protocol, net_socket **_socket)
|
||||
static status_t
|
||||
create_socket(int family, int type, int protocol, net_socket **_socket)
|
||||
{
|
||||
struct net_socket *socket = new (std::nothrow) net_socket;
|
||||
if (socket == NULL)
|
||||
@@ -55,15 +55,9 @@ socket_create(int family, int type, int protocol, net_socket **_socket)
|
||||
if (status < B_OK)
|
||||
goto err2;
|
||||
|
||||
status = socket->first_info->open(socket->first_protocol);
|
||||
if (status < B_OK)
|
||||
goto err3;
|
||||
|
||||
*_socket = socket;
|
||||
return B_OK;
|
||||
|
||||
err3:
|
||||
put_domain_protocols(socket);
|
||||
err2:
|
||||
benaphore_destroy(&socket->lock);
|
||||
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
|
||||
socket_close(net_socket *socket)
|
||||
{
|
||||
@@ -200,7 +216,7 @@ socket_spawn_pending(net_socket *parent, net_socket **_socket)
|
||||
return ENOBUFS;
|
||||
|
||||
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)
|
||||
return status;
|
||||
|
||||
@@ -797,7 +813,7 @@ net_socket_module_info gNetSocketModule = {
|
||||
0,
|
||||
socket_std_ops
|
||||
},
|
||||
socket_create,
|
||||
socket_open,
|
||||
socket_close,
|
||||
socket_free,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user