Fix stale socket rebinding and re-enable python tests for Windows #6590

pull theuni wants to merge 2 commits into bitcoin:master from theuni:windows-python-tests changing 2 files +3 −6
  1. theuni commented at 4:06 pm on August 25, 2015: member

    The fix is debatable, but it points out the real issue: when testing with Windows, stale sockets from previous runs cause the current tests’ listen sockets to be unavailable, leading to nodes that never sync. I’m sure that translates to real-world issues as well, for example watchdog scripts would likely fail to work as intended. I’m not sure if there’s a more proper way to fix the problem for Windows, so I just copied the behavior we already use for Unix.

    This may be part of the root cause of #6554, but I’m not sure about that.

    With that fixed, these test run fine locally. Note that they do take quite a while to run though, so we might not want to enable them on Travis for every PR/push.

  2. net: Set SO_REUSEADDR for Windows too
    When running the rpc tests in Wine, nodes often fail to listen on localhost
    due to a stale socket from a previous run. This aligns the behavior with other
    platforms.
    a19338723d
  3. rpc-tests: re-enable rpc-tests for Windows bd30c3dced
  4. theuni commented at 4:22 pm on August 25, 2015: member

    Grr, I forgot to mention here that this is only known to fix issues with running the Windows tests on Linux via Wine. This isn’t a substitute for #6548 which aims to fix them when running natively.

    Imo it’d be easier to make sure they work with Travis first, so we can ensure that any fixes for native Windows don’t cause any regressions.

  5. theuni renamed this:
    Re-enable python tests for Windows
    Fix stale socket rebinding and re-enable python tests for Windows
    on Aug 25, 2015
  6. ptschip commented at 5:33 pm on August 25, 2015: contributor

    Cory,

    From you pull request I downloaded and built on native windows and can confirm that those changes do “not” fix issue 6554

    however,

    I saw that the tests for windows, “on linux” did pass, so that was good.

    The only request I have is that you try running that build with your changes at least 2 more times. The reason is that the issue, at least with 6554, is only intermittent and happens roughly 30 to 50% of the time.

    On 25/08/2015 9:23 AM, Cory Fields wrote:

    Grr, I forgot to mention here that this is only known to fix issues with running the Windows tests on Linux via Wine. This isn’t a substitute for #6548 #6548 which aims to fix them when running natively.

    Imo it’d be easier to make sure they work with Travis first, so we can ensure that any fixes for native Windows don’t cause any regressions.

    — Reply to this email directly or view it on GitHub #6590 (comment).

  7. theuni commented at 6:28 pm on August 25, 2015: member

    The issue that this fixes is 100% reproducible, it happens every time without the fix, and never with it. I’ll admit that I’m puzzled as to why it doesn’t happen on native Windows, though. Maybe it has to do with how quickly the processes are spun up.

    I think it’s safe to say they’re separate issues.

  8. ptschip commented at 6:47 pm on August 25, 2015: contributor
    That’s great…when this fix get’s merged I’ll make the changes to the “enable python scripts for windows” without the travis.yml updates.
  9. Diapolo commented at 8:06 pm on August 25, 2015: none
    IMHO this change wont hurt even when applied to native Windows. I’m going to integrate it into my local build and will run my 2 partially online nodes with it applied and see what happens ;). Perhaps there are other ifdef cases that apply settings/state for Linux but not Windows…
  10. in src/net.cpp: in bd30c3dced
    1624@@ -1625,8 +1625,10 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
    1625     setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
    1626 #endif
    1627     // Allow binding if the port is still in TIME_WAIT state after
    1628-    // the program was closed and restarted. Not an issue on windows!
    1629+    // the program was closed and restarted.
    1630     setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));
    1631+#else
    1632+    setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&nOne, sizeof(int));
    


    laanwj commented at 9:44 am on August 26, 2015:
    Verified that this is the correct type: type of SO_REUSEADDR’s value is a BOOL according to MS’ API docs, and BOOL is a typedef of int. nOne is an int.
  11. laanwj commented at 9:59 am on August 26, 2015: member
    utACK
  12. laanwj merged this on Aug 26, 2015
  13. laanwj closed this on Aug 26, 2015

  14. laanwj referenced this in commit 981fd92bc5 on Aug 26, 2015
  15. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me