Inconsistent Trickle Down Message Behavior

Message boards : API : Inconsistent Trickle Down Message Behavior
Message board moderation

To post messages, you must log in.

AuthorMessage
Thomas

Send message
Joined: 23 Oct 15
Posts: 5
United States
Message 68027 - Posted: 27 Feb 2016, 2:43:29 UTC

Hi all,

I would like to add trickle_down message handling to my app. I am experiencing some strange and sporadic behavior from my implementation (I used https://boinc.berkeley.edu/trac/wiki/TrickleApi, as well as uc2.cpp and trickle_echo.cpp to help me complete it). I would like the app to send a trickle_up message, and then have it "echoed" back to the app from the server. It looks like the trickle_up message and the trickle handler are working, at least from what I can see in the database. Around 50% of the time, the trickle_down message never reaches the app. In the times that my app DOES pick up a trickle_down message, it reads something like this:

trickle_ (19655):


when the message in the database's "msg_to_host" is:

<trickle_down>

      <result_name>test_app_nodelete_0</result_name>
      <time>1456539574</time>
what am I?
</trickle_down>


To receive the trickle_down message I have created a loop which periodically polls for the presence of a reply. I've included that code below. As it is written now, it will very often timeout, but if I remove the timeout the system simply hangs indefinitely every other time I run it.

int retrieve_trickle_reply(char* reply) {
    int retval, i = 0;
    char buf[256];

    // Poll periodically until trickle recieved or timeout
    retval = boinc_receive_trickle_down(reply, sizeof(reply));
    while (!retval && i < TIMEOUT) {
        boinc_sleep(POLL_IVAL);
        retval = boinc_receive_trickle_down(reply, sizeof(reply));
        ++i;
    }

    fprintf(stderr, "%s i count is: %d\n",
        boinc_msg_prefix(buf, sizeof(buf)), i
    );

    fprintf(stderr, "%s reply is: %s\n",
        boinc_msg_prefix(buf, sizeof(buf)), reply
    );

    if (i == TIMEOUT) {
        return 1;
    }

    return 0;
}


Any ideas? Another note: I know that in uc2.cpp the return value of "boinc_receive_trickle_down" is treated as if "0" is a reply and any other value is "no reply". Looking at the source code I am fairly confident that it is the other way around. In any case I have tried both interpretations and neither works.

Thanks!
Thomas
ID: 68027 · Report as offensive
James Kernow

Send message
Joined: 15 Mar 16
Posts: 1
United Kingdom
Message 68304 - Posted: 15 Mar 2016, 15:32:02 UTC - in response to Message 68027.  

Check your buffer is large enough. You are holding the thread back with sleep. I would suggest freeing up the thread and not timing out to diagnose.
ID: 68304 · Report as offensive
Thomas

Send message
Joined: 23 Oct 15
Posts: 5
United States
Message 68322 - Posted: 16 Mar 2016, 2:55:47 UTC - in response to Message 68304.  

Hi James,

Thanks so much for the reply! The buffer size sounds like a good place to look. Do you mind expanding on what you mean by "holding the thread back with sleep"? Specifically I would be curious to understand the causal chain of consequences this has - I have been treating boinc-sleep essentially as the system "sleep" command. Is there a more BOINC-idiomatic approach to implementing my busy wait routine?
ID: 68322 · Report as offensive

Message boards : API : Inconsistent Trickle Down Message Behavior

Copyright © 2024 University of California.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.