Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-1435

Out-by-one errors in port_range handling

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 3.1
    • 3.0.6, 3.1
    • None

    Description

      Various mismatches between documentation and code for port_range handling. I don't know which you prefer to fix. It would also be desirable if the behaviour was consistent between different protocols.

      BPING says

      @Property(description="Sends discovery packets to ports 8555 to (8555+port_range)")

      but the code goes

      for(int i=bind_port; i < bind_port+port_range; i++) {

      so actually packets go to 8555+port_range-1, and value 0 is meaningless. Probably that should be a <= there (with corresponding fixes required in a couple of other places in the file).

      FD_SOCK says

      @Property(description="Number of ports to probe for start_port and client_bind_port")

      but in setupPingSocket(), the code goes

      if(num_bind_attempts++ > port_range) {

      Since this is a post-increment, we'll actually try not one but two more ports than promised. Eg if port_range is zero, we'll try both client_bind_port and client_bind_port+1. Probably you want to change this to a pre-increment, and also change the documentation to describe what actually happens.

      I believe that TCPPING and TP both behave as advertised, ie:

      @Property(description="The range of valid ports, from bind_port to end_port. 0 only binds to bind_port and fails if taken")

      ... and my suggestion would be that this is what you really want in all cases.

      Attachments

        Activity

          People

            rhn-engineering-bban Bela Ban
            dimbleby David Hotham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: