Skip to content

Commit

Permalink
proxy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matanbroner committed Mar 27, 2023
1 parent f63900c commit fc75cd0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions tc_server_py/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,23 @@ def read_and_forward(self, sock):
"""
cfd, sfd = sock, self.forward_map[sock.fileno()]
try:
subflow_tcp_info = get_subflow_tcp_info(sfd.fileno())
subflow_tcp_info = get_subflow_tcp_info(cfd.fileno())
for subflow in subflow_tcp_info:
if subflow:
if isinstance(subflow, dict):
logger.info("Subflow {}: {}".format(subflow["id"], subflow["tcpi_rtt"]))
continue
except Exception as e:
logger.error(e)
if sfd.fileno() == -1 or cfd.fileno() == -1:
# Close both sockets
logger.info("Socket pair is closed, closing sockets")
self.cleanup_socket_pair(cfd, sfd)
data = sock.recv(BUFFER_SIZE)
try:
data = sock.recv(BUFFER_SIZE)
except Exception as e:
logger.error(e)
self.cleanup_socket_pair(cfd, sfd)
return
if data:
# Forward data to the other socket
self.forward_map[sock.fileno()].send(data)
Expand Down
4 changes: 3 additions & 1 deletion tc_server_py/mptctp_util/mptcp_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ PyObject * mptcp_util_get_subflow_tcp_info(PyObject *self, PyObject *args)
}
// Create a list to hold all subflows as individual dictionaries
int num_subflows = (int)(addrs.d.num_subflows);
PyObject *subflow_list = PyList_New(num_subflows);
printf("Num subflows: %d\n", num_subflows);
PyObject *subflow_list = PyList_New(0);
// Iterate through each subflow and add it to the list
for (int i = 0; i < num_subflows; i++)
{
Expand Down Expand Up @@ -166,6 +167,7 @@ PyObject * mptcp_util_get_subflow_tcp_info(PyObject *self, PyObject *args)
PyDict_SetItemString(subflow_dict, "tcpi_rcv_space", PyLong_FromLong(ti->tcpi_rcv_space));
PyDict_SetItemString(subflow_dict, "tcpi_total_retrans", PyLong_FromLong(ti->tcpi_total_retrans));


// Add the subflow dictionary to the list
PyList_Append(subflow_list, subflow_dict);
}
Expand Down

0 comments on commit fc75cd0

Please sign in to comment.