fixed getsockopt/setsockopt callchains. also fixed the cleanup of multicast filters.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20923 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -257,12 +257,14 @@ MulticastFilter<Addressing>::MulticastFilter(ProtocolType *socket)
|
|||||||
template<typename Addressing>
|
template<typename Addressing>
|
||||||
MulticastFilter<Addressing>::~MulticastFilter()
|
MulticastFilter<Addressing>::~MulticastFilter()
|
||||||
{
|
{
|
||||||
typename States::Iterator iterator = fStates.GetIterator();
|
while (true) {
|
||||||
while (iterator.HasNext()) {
|
typename States::Iterator iterator = fStates.GetIterator();
|
||||||
|
if (!iterator.HasNext())
|
||||||
|
return;
|
||||||
|
|
||||||
GroupState *state = iterator.Next();
|
GroupState *state = iterator.Next();
|
||||||
state->Clear();
|
state->Clear();
|
||||||
ReturnGroup(state);
|
_ReturnGroup(state);
|
||||||
iterator.Rewind();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,11 +298,17 @@ MulticastFilter<Addressing>::GetGroup(const AddressType &groupAddress,
|
|||||||
template<typename Addressing> void
|
template<typename Addressing> void
|
||||||
MulticastFilter<Addressing>::ReturnGroup(GroupState *group)
|
MulticastFilter<Addressing>::ReturnGroup(GroupState *group)
|
||||||
{
|
{
|
||||||
if (group->IsEmpty()) {
|
if (group->IsEmpty())
|
||||||
Addressing::LeaveGroup(group);
|
_ReturnGroup(group);
|
||||||
fStates.Remove(group);
|
}
|
||||||
delete group;
|
|
||||||
}
|
|
||||||
|
template<typename Addressing> void
|
||||||
|
MulticastFilter<Addressing>::_ReturnGroup(GroupState *group)
|
||||||
|
{
|
||||||
|
Addressing::LeaveGroup(group);
|
||||||
|
fStates.Remove(group);
|
||||||
|
delete group;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPv4 explicit template instantiation
|
// IPv4 explicit template instantiation
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ private:
|
|||||||
typedef typename GroupState::HashDefinition GroupHashDefinition;
|
typedef typename GroupState::HashDefinition GroupHashDefinition;
|
||||||
typedef OpenHashTable<GroupHashDefinition> States;
|
typedef OpenHashTable<GroupHashDefinition> States;
|
||||||
|
|
||||||
|
void _ReturnGroup(GroupState *group);
|
||||||
|
|
||||||
ProtocolType *fParent;
|
ProtocolType *fParent;
|
||||||
States fStates;
|
States fStates;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -749,8 +749,12 @@ socket_getsockopt(net_socket *socket, int level, int option, void *value,
|
|||||||
{
|
{
|
||||||
status_t status = (level == SOL_SOCKET) ? B_OK : B_BAD_VALUE;
|
status_t status = (level == SOL_SOCKET) ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
if (socket->first_info->getsockopt)
|
net_protocol *protocol = socket->first_protocol;
|
||||||
status = socket->first_info->getsockopt(socket->first_protocol, level,
|
while (protocol && protocol->module->getsockopt == NULL)
|
||||||
|
protocol = protocol->next;
|
||||||
|
|
||||||
|
if (protocol)
|
||||||
|
status = protocol->module->getsockopt(protocol, level,
|
||||||
option, value, _length);
|
option, value, _length);
|
||||||
|
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
@@ -1066,9 +1070,13 @@ socket_setsockopt(net_socket *socket, int level, int option, const void *value,
|
|||||||
{
|
{
|
||||||
status_t status = (level == SOL_SOCKET) ? B_OK : B_BAD_VALUE;
|
status_t status = (level == SOL_SOCKET) ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
if (socket->first_info->setsockopt)
|
net_protocol *protocol = socket->first_protocol;
|
||||||
status = socket->first_info->setsockopt(socket->first_protocol, level,
|
while (protocol && protocol->module->setsockopt == NULL)
|
||||||
option, value, length);
|
protocol = protocol->next;
|
||||||
|
|
||||||
|
if (protocol)
|
||||||
|
status = protocol->module->setsockopt(protocol, level, option,
|
||||||
|
value, length);
|
||||||
|
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
inet_pton(AF_INET, argv[1], &mreq.imr_multiaddr);
|
inet_pton(AF_INET, argv[1], &mreq.imr_multiaddr);
|
||||||
|
|
||||||
setsockopt(sock, AF_INET, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
|
setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int len = recv(sock, buf, sizeof(buf), 0);
|
int len = recv(sock, buf, sizeof(buf), 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user