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
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (6645343) 74.51% compared to head (51a803f) 74.64%.

❗ Current head 51a803f differs from pull request most recent head c200f9c. Consider uploading reports for the commit c200f9c to get more accurate results

Files Patch % Lines
toxcore/tox.c 88.88% 9 Missing ⚠️
toxcore/TCP_connection.c 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1821      +/-   ##
==========================================
+ Coverage   74.51%   74.64%   +0.12%     
==========================================
  Files          87       87              
  Lines       26313    26334      +21     
==========================================
+ Hits        19607    19656      +49     
+ Misses       6706     6678      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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
4 participants