Commit ade2a06
committed
Correctly connect parties with socket. (#218)
Summary:
Pull Request resolved: #218
Our existing arrangement of party info (ip address and port number) is buggy as there will be a conflict with more than 2 parties. This diff is to address this issue.
Our current code works fine with 2 party setting. But it will break with more than 2 parties.
Example scenario:
when party 0 connects with party 1, with current code, he will pull out the partyinfo of party 0, and add one to the port number. Party 1 will add 1 to a port number on his side.
When party 1 connects with party 2, with current code, he will pull out the same partyinfo of party 0, and add on to the port number. Party 2 will add 1 to a port number on his side.
Since multiple connections will be established between each pair of parties, this will definitely create a conflict. For example, party 0 will add 1 to the same port number twice while others only do that once.
Our solution:
1. Each party keep a map of partyinfo, served as "info needed to connected to party i".
2. during each connection attemption, each party will use the peer's id to look up the partyinfo map. If this party is going to play the role of server, the ip address is useless. The corresponding ip address and port number can be used to establish connection.
Differential Revision: D36908724
fbshipit-source-id: 7821ade91cfb8c61be76cf79547ef8a4fdc8c4761 parent 40b0a5c commit ade2a06
3 files changed
Lines changed: 72 additions & 27 deletions
File tree
- fbpcf/engine
- communication
- test
- util/test/benchmarks
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| |||
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
54 | | - | |
55 | | - | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| |||
Lines changed: 52 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
57 | | - | |
58 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
59 | 71 | | |
60 | 72 | | |
61 | 73 | | |
| |||
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
76 | | - | |
77 | | - | |
78 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
79 | 98 | | |
80 | 99 | | |
81 | | - | |
| 100 | + | |
82 | 101 | | |
83 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
84 | 105 | | |
85 | 106 | | |
86 | | - | |
87 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
88 | 110 | | |
| 111 | + | |
89 | 112 | | |
90 | 113 | | |
91 | 114 | | |
| |||
97 | 120 | | |
98 | 121 | | |
99 | 122 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
103 | 133 | | |
104 | 134 | | |
105 | | - | |
| 135 | + | |
106 | 136 | | |
107 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
108 | 140 | | |
109 | 141 | | |
110 | | - | |
111 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
112 | 145 | | |
| 146 | + | |
113 | 147 | | |
114 | 148 | | |
115 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
51 | | - | |
52 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | | - | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | | - | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
0 commit comments