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:
parent
3df919a7a0
commit
57967505c2
@ -257,12 +257,14 @@ MulticastFilter<Addressing>::MulticastFilter(ProtocolType *socket)
|
||||
template<typename Addressing>
|
||||
MulticastFilter<Addressing>::~MulticastFilter()
|
||||
{
|
||||
typename States::Iterator iterator = fStates.GetIterator();
|
||||
while (iterator.HasNext()) {
|
||||
while (true) {
|
||||
typename States::Iterator iterator = fStates.GetIterator();
|
||||
if (!iterator.HasNext())
|
||||
return;
|
||||
|
||||
GroupState *state = iterator.Next();
|
||||
state->Clear();
|
||||
ReturnGroup(state);
|
||||
iterator.Rewind();
|
||||
_ReturnGroup(state);
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,11 +298,17 @@ MulticastFilter<Addressing>::GetGroup(const AddressType &groupAddress,
|
||||
template<typename Addressing> void
|
||||
MulticastFilter<Addressing>::ReturnGroup(GroupState *group)
|
||||
{
|
||||
if (group->IsEmpty()) {
|
||||
Addressing::LeaveGroup(group);
|
||||
fStates.Remove(group);
|
||||
delete group;
|
||||
}
|
||||
if (group->IsEmpty())
|
||||
_ReturnGroup(group);
|
||||
}
|
||||
|
||||
|
||||
template<typename Addressing> void
|
||||
MulticastFilter<Addressing>::_ReturnGroup(GroupState *group)
|
||||
{
|
||||
Addressing::LeaveGroup(group);
|
||||
fStates.Remove(group);
|
||||
delete group;
|
||||
}
|
||||
|
||||
// IPv4 explicit template instantiation
|
||||
|
@ -160,6 +160,8 @@ private:
|
||||
typedef typename GroupState::HashDefinition GroupHashDefinition;
|
||||
typedef OpenHashTable<GroupHashDefinition> States;
|
||||
|
||||
void _ReturnGroup(GroupState *group);
|
||||
|
||||
ProtocolType *fParent;
|
||||
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;
|
||||
|
||||
if (socket->first_info->getsockopt)
|
||||
status = socket->first_info->getsockopt(socket->first_protocol, level,
|
||||
net_protocol *protocol = socket->first_protocol;
|
||||
while (protocol && protocol->module->getsockopt == NULL)
|
||||
protocol = protocol->next;
|
||||
|
||||
if (protocol)
|
||||
status = protocol->module->getsockopt(protocol, level,
|
||||
option, value, _length);
|
||||
|
||||
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;
|
||||
|
||||
if (socket->first_info->setsockopt)
|
||||
status = socket->first_info->setsockopt(socket->first_protocol, level,
|
||||
option, value, length);
|
||||
net_protocol *protocol = socket->first_protocol;
|
||||
while (protocol && protocol->module->setsockopt == NULL)
|
||||
protocol = protocol->next;
|
||||
|
||||
if (protocol)
|
||||
status = protocol->module->setsockopt(protocol, level, option,
|
||||
value, length);
|
||||
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
@ -30,7 +30,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
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) {
|
||||
int len = recv(sock, buf, sizeof(buf), 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user