Skip to content

Commit

Permalink
[API] Removed unused srt_include(..) and srt_exclude(..) API functions
Browse files Browse the repository at this point in the history
for unimplemented externally managed groups.
  • Loading branch information
maxsharabayko committed May 2, 2022
1 parent f1a6415 commit 94ff168
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 151 deletions.
32 changes: 0 additions & 32 deletions docs/API/API-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
| [SRT_SOCKGROUPDATA](#SRT_SOCKGROUPDATA) | Most important structure for group member status |
| [SRT_MEMBERSTATUS](#SRT_MEMBERSTATUS) | Enumeration type that defines the state of a member connection in the group |
| [srt_create_group](#srt_create_group) | Creates a new group of type `type` |
| [srt_include](#srt_include) | Adds a socket to a group |
| [srt_exclude](#srt_exclude) | Removes a socket from a group to which it currently belongs |
| [srt_groupof](#srt_groupof) | Returns the group ID of a socket, or `SRT_INVALID_SOCK` |
| [srt_group_data](#srt_group_data) | Obtains the current member state of the group specified in `socketgroup` |
| [srt_connect_group](#srt_connect_group) | Similar to calling [`srt_connect`](#srt_connect) or [`srt_connect_bind`](#srt_connect_bind) <br/> in a loop for every item in an array. |
Expand Down Expand Up @@ -1138,8 +1136,6 @@ become `SRT_GST_IDLE`).
### Functions to Be Used on Groups

* [srt_create_group](#srt_create_group)
* [srt_include](#srt_include)
* [srt_exclude](#srt_exclude)
* [srt_groupof](#srt_groupof)
* [srt_group_data](#srt_group_data)
* [srt_connect_group](#srt_connect_group)
Expand All @@ -1160,34 +1156,6 @@ The group ID is of the same domain as the socket ID, with the exception that
the `SRTGROUP_MASK` bit is set on it, unlike for socket ID.


[:arrow_up: &nbsp; Back to List of Functions & Structures](#srt-api-functions)

---

#### srt_include

```
int srt_include(SRTSOCKET socket, SRTSOCKET group);
```

This function adds a socket to a group. This is only allowed for unmanaged
groups. No such group type is currently implemented.


[:arrow_up: &nbsp; Back to List of Functions & Structures](#srt-api-functions)

---

#### srt_exclude

```
int srt_exclude(SRTSOCKET socket);
```
This function removes a socket from a group to which it currently belongs.
This is only allowed for unmanaged groups. No such group type is currently
implemented.


[:arrow_up: &nbsp; Back to List of Functions & Structures](#srt-api-functions)

---
Expand Down
77 changes: 0 additions & 77 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,14 +1276,6 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i
CUDTGroup& g = *pg;
SRT_ASSERT(g.m_iBusy > 0);

// The group must be managed to use srt_connect on it,
// as it must create particular socket automatically.

// Non-managed groups can't be "connected" - at best you can connect
// every socket individually.
if (!g.managed())
throw CUDTException(MJ_NOTSUP, MN_INVAL);

// Check and report errors on data brought in by srt_prepare_endpoint,
// as the latter function has no possibility to report errors.
for (int tii = 0; tii < arraysize; ++tii)
Expand Down Expand Up @@ -3266,75 +3258,6 @@ SRTSOCKET srt::CUDT::createGroup(SRT_GROUP_TYPE gt)
return SRT_INVALID_SOCK;
}

int srt::CUDT::addSocketToGroup(SRTSOCKET socket, SRTSOCKET group)
{
// Check if socket and group have been set correctly.
int32_t sid = socket & ~SRTGROUP_MASK;
int32_t gm = group & SRTGROUP_MASK;

if (sid != socket || gm == 0)
return APIError(MJ_NOTSUP, MN_INVAL, 0);

// Find the socket and the group
CUDTSocket* s = uglobal().locateSocket(socket);
CUDTUnited::GroupKeeper k(uglobal(), group, CUDTUnited::ERH_RETURN);

if (!s || !k.group)
return APIError(MJ_NOTSUP, MN_INVAL, 0);

// Check if the socket is already IN SOME GROUP.
if (s->m_GroupOf)
return APIError(MJ_NOTSUP, MN_INVAL, 0);

CUDTGroup* g = k.group;
if (g->managed())
{
// This can be changed as long as the group is empty.
if (!g->groupEmpty())
{
return APIError(MJ_NOTSUP, MN_INVAL, 0);
}
g->set_managed(false);
}

ScopedLock cg(s->m_ControlLock);
ScopedLock cglob(uglobal().m_GlobControlLock);
if (g->closing())
return APIError(MJ_NOTSUP, MN_INVAL, 0);

// Check if the socket already is in the group
srt::groups::SocketData* f;
if (g->contains(socket, (f)))
{
// XXX This is internal error. Report it, but continue
LOGC(aclog.Error, log << "IPE (non-fatal): the socket is in the group, but has no clue about it!");
s->m_GroupMemberData = f;
s->m_GroupOf = g;
return 0;
}
s->m_GroupMemberData = g->add(srt::groups::prepareSocketData(s));
s->m_GroupOf = g;

return 0;
}

// dead function as for now. This is only for non-managed
// groups.
int srt::CUDT::removeSocketFromGroup(SRTSOCKET socket)
{
CUDTSocket* s = uglobal().locateSocket(socket);
if (!s)
return APIError(MJ_NOTSUP, MN_INVAL, 0);

if (!s->m_GroupOf)
return APIError(MJ_NOTSUP, MN_INVAL, 0);

ScopedLock cg(s->m_ControlLock);
ScopedLock glob_grd(uglobal().m_GlobControlLock);
s->removeFromGroup(false);
return 0;
}

// [[using locked(m_ControlLock)]]
// [[using locked(CUDT::s_UDTUnited.m_GlobControlLock)]]
void srt::CUDTSocket::removeFromGroup(bool broken)
Expand Down
2 changes: 0 additions & 2 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ class CUDT
static SRTSOCKET socket();
#if ENABLE_EXPERIMENTAL_BONDING
static SRTSOCKET createGroup(SRT_GROUP_TYPE);
static int addSocketToGroup(SRTSOCKET socket, SRTSOCKET group);
static int removeSocketFromGroup(SRTSOCKET socket);
static SRTSOCKET getGroupOfSocket(SRTSOCKET socket);
static int getGroupData(SRTSOCKET groupid, SRT_SOCKGROUPDATA* pdata, size_t* psize);
static int configureGroup(SRTSOCKET groupid, const char* str);
Expand Down
35 changes: 1 addition & 34 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ CUDTGroup::CUDTGroup(SRT_GROUP_TYPE gtype)
: m_Global(CUDT::uglobal())
, m_GroupID(-1)
, m_PeerGroupID(-1)
, m_selfManaged(true)
, m_bSyncOnMsgNo(false)
, m_type(gtype)
, m_listener()
Expand Down Expand Up @@ -291,29 +290,7 @@ CUDTGroup::CUDTGroup(SRT_GROUP_TYPE gtype)
// two or more sockets start arguing about it.
m_iLastSchedSeqNo = CUDT::generateISN();

// Configure according to type
switch (gtype)
{
case SRT_GTYPE_BROADCAST:
m_selfManaged = true;
break;

case SRT_GTYPE_BACKUP:
m_selfManaged = true;
break;

case SRT_GTYPE_BALANCING:
m_selfManaged = true;
m_bSyncOnMsgNo = true;
break;

case SRT_GTYPE_MULTICAST:
m_selfManaged = false;
break;

default:
break;
}
m_bSyncOnMsgNo = (gtype == SRT_GTYPE_BALANCING);
}

CUDTGroup::~CUDTGroup()
Expand Down Expand Up @@ -937,16 +914,6 @@ void CUDTGroup::close()
ScopedLock glob(CUDT::uglobal().m_GlobControlLock);
ScopedLock g(m_GroupLock);

// A non-managed group may only be closed if there are no
// sockets in the group.

// XXX Fortunately there are currently no non-self-managed
// groups, so this error cannot ever happen, but this error
// has the overall code suggesting that it's about the listener,
// so either the name should be changed here, or a different code used.
if (!m_selfManaged && !m_Group.empty())
throw CUDTException(MJ_NOTSUP, MN_BUSY, 0);

m_bClosing = true;

// Copy the list of IDs into the array.
Expand Down
2 changes: 0 additions & 2 deletions srtcore/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ class CUDTGroup
void erase(gli_t it);
};
GroupContainer m_Group;
bool m_selfManaged;
bool m_bSyncOnMsgNo;
SRT_GROUP_TYPE m_type;
CUDTSocket* m_listener; // A "group" can only have one listener.
Expand Down Expand Up @@ -811,7 +810,6 @@ class CUDTGroup
// Property accessors
SRTU_PROPERTY_RW_CHAIN(CUDTGroup, SRTSOCKET, id, m_GroupID);
SRTU_PROPERTY_RW_CHAIN(CUDTGroup, SRTSOCKET, peerid, m_PeerGroupID);
SRTU_PROPERTY_RW_CHAIN(CUDTGroup, bool, managed, m_selfManaged);
SRTU_PROPERTY_RW_CHAIN(CUDTGroup, SRT_GROUP_TYPE, type, m_type);
SRTU_PROPERTY_RW_CHAIN(CUDTGroup, int32_t, currentSchedSequence, m_iLastSchedSeqNo);
SRTU_PROPERTY_RRW(std::set<int>&, epollset, m_sPollID);
Expand Down
2 changes: 0 additions & 2 deletions srtcore/srt.h
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,6 @@ typedef struct SRT_GroupMemberConfig_
} SRT_SOCKGROUPCONFIG;

SRT_API SRTSOCKET srt_create_group (SRT_GROUP_TYPE);
SRT_API int srt_include (SRTSOCKET socket, SRTSOCKET group);
SRT_API int srt_exclude (SRTSOCKET socket);
SRT_API SRTSOCKET srt_groupof (SRTSOCKET socket);
SRT_API int srt_group_data (SRTSOCKET socketgroup, SRT_SOCKGROUPDATA* output, size_t* inoutlen);
SRT_API int srt_group_configure(SRTSOCKET socketgroup, const char* str);
Expand Down
2 changes: 0 additions & 2 deletions srtcore/srt_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ SRTSOCKET srt_create_socket() { return CUDT::socket(); }
#if ENABLE_EXPERIMENTAL_BONDING
// Group management.
SRTSOCKET srt_create_group(SRT_GROUP_TYPE gt) { return CUDT::createGroup(gt); }
int srt_include(SRTSOCKET socket, SRTSOCKET group) { return CUDT::addSocketToGroup(socket, group); }
int srt_exclude(SRTSOCKET socket) { return CUDT::removeSocketFromGroup(socket); }
SRTSOCKET srt_groupof(SRTSOCKET socket) { return CUDT::getGroupOfSocket(socket); }
int srt_group_data(SRTSOCKET socketgroup, SRT_SOCKGROUPDATA* output, size_t* inoutlen)
{
Expand Down

0 comments on commit 94ff168

Please sign in to comment.