Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add back the tox_loop implementation for low latency. #1821

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Dec 29, 2021

Copied code from #335.

Fixes #225.


This change is Reviewable

@iphydf iphydf added this to the v0.2.x milestone Dec 29, 2021
@auto-add-label auto-add-label bot added the enhancement New feature for the user, not a new feature for build script label Dec 29, 2021
@iphydf iphydf force-pushed the tox-loop branch 2 times, most recently from f8ce6f6 to e18504e Compare December 29, 2021 02:23
Copy link
Member

@JFreegman JFreegman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 12 of 12 files at r1, all commit messages.
Reviewable status: 0 of 1 approvals obtained (waiting on @iphydf)


auto_tests/tox_loop_test.c, line 20 at r1 (raw file):

typedef struct {
    int start_count, stop_count;

Should be on separate lines


auto_tests/tox_loop_test.c, line 49 at r1 (raw file):

{
    pthread_t worker, worker_tcp;
    struct Tox_Options *opts = tox_options_new(NULL);

nullptr (this needs to be fixed PR-wide)


toxcore/Messenger.c, line 1911 at r1 (raw file):

#if defined(HAVE_LIBEV) || defined(HAVE_LIBEVENT)

    if (!m->dispatcher) {

== nullptr


toxcore/TCP_connection.c, line 63 at r1 (raw file):

 * Return number of elements of TCP connection array.
 *
 * @param tcp_c struct containing TCP_con array

Lots of missing .'s in the comments


toxcore/tox.c, line 875 at r1 (raw file):

    uint32_t len = tcp_connections_length(nc_get_tcp_c(m->net_crypto));

    for (uint32_t i = 0; i < len; i++) {

++i (one of many)


toxcore/tox.c, line 1025 at r1 (raw file):

#endif

bool tox_loop(Tox *tox, void *user_data, TOX_ERR_LOOP *error)

Would it make sense to split this up via helper functions for each ifdef condition?


toxcore/tox.c, line 1037 at r1 (raw file):

#ifdef HAVE_LIBEV
    bool ret = true;
    Event_Arg *tmp = (Event_Arg *) calloc(1, sizeof(Event_Arg));

Missing null check after calloc


toxcore/tox.c, line 1070 at r1 (raw file):

    free(tmp);
#elif defined(HAVE_LIBEVENT)
    Event_Arg *tmp = (Event_Arg *) calloc(1, sizeof(Event_Arg));

Missing null check after calloc

Copy link

@sudden6 sudden6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @iphydf)


auto_tests/tox_loop_test.c, line 11 at r2 (raw file):

#define TCP_RELAY_PORT 33448
/* The Travis-CI container responds poorly to ::1 as a localhost address

We don't use Travis anymore, still needed? At least update the comment


toxcore/tox.c, line 947 at r2 (raw file):

    uint32_t i = 0;

    while (i < fdcount - 1 && i < len) {

this could be rewritten as for loop with upper bound of len since fdcount = len + 1 a few lines above, which is easier to read. This whole section could use some cleanup.


toxcore/tox.c, line 994 at r2 (raw file):

    // TODO(Ansa89): travis states that "ev_run" returns "void",
    // but "man 3 ev" states it returns "bool"
#if 0

don't commit dead code?


toxcore/tox.c, line 1083 at r2 (raw file):

    free(fdlist);
#endif

which #if terminates here? I'd generally add a comment if the preprocessor instructions are nested or span several lines

@iphydf iphydf force-pushed the tox-loop branch 13 times, most recently from b226f14 to e6e195c Compare December 29, 2021 19:49
@iphydf iphydf force-pushed the tox-loop branch 2 times, most recently from 247d058 to dec479e Compare December 20, 2023 14:31
@iphydf iphydf force-pushed the tox-loop branch 2 times, most recently from a0ca575 to a3a9df6 Compare December 28, 2023 23:55
@iphydf iphydf force-pushed the tox-loop branch 2 times, most recently from 36aae48 to d0dec04 Compare January 17, 2024 22:51
@iphydf iphydf force-pushed the tox-loop branch 4 times, most recently from ec9309a to d47f9ca Compare January 27, 2024 00:02
@iphydf iphydf force-pushed the tox-loop branch 5 times, most recently from dd61134 to 38a0587 Compare February 2, 2024 23:52
@iphydf iphydf force-pushed the tox-loop branch 2 times, most recently from 40eccaf to b335fc2 Compare February 12, 2024 01:06
@iphydf iphydf force-pushed the tox-loop branch 2 times, most recently from 86f43fe to 489a7f5 Compare March 5, 2024 12:33
@iphydf iphydf modified the milestones: v0.2.20, v0.2.21 Mar 28, 2024
@iphydf iphydf force-pushed the tox-loop branch 2 times, most recently from babffab to 7ae3922 Compare November 8, 2024 15:11
@iphydf iphydf modified the milestones: v0.2.21, v0.2.x Nov 27, 2024
@@ -197,6 +197,12 @@ endif()
# We don't transfer floats over the network, so we disable this functionality.
add_definitions(-DCMP_NO_FLOAT=1)

# TODO(iphydf): Check whether this is actually true.
option(USE_LIBEV "Whether to use libev for tox_loop" OFF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options should have a prefix like TOX_ or TOXCORE_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature for the user, not a new feature for build script
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add public low latency API
5 participants