mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-08 19:50:23 -04:00
Store handShakeComplete only after the player has been added to the player list.
This prevents a race condition between reconnecting and being added to the list. Should fix #999
This commit is contained in:
parent
a0365dabd9
commit
9be4ff1047
@ -637,7 +637,7 @@ pub const Protocols = struct {
|
|||||||
const stepUserData: u8 = 1;
|
const stepUserData: u8 = 1;
|
||||||
const stepAssets: u8 = 2;
|
const stepAssets: u8 = 2;
|
||||||
const stepServerData: u8 = 3;
|
const stepServerData: u8 = 3;
|
||||||
const stepComplete: u8 = 255;
|
pub const stepComplete: u8 = 255;
|
||||||
|
|
||||||
fn receive(conn: *Connection, data: []const u8) !void {
|
fn receive(conn: *Connection, data: []const u8) !void {
|
||||||
if(conn.handShakeState.load(.monotonic) < data[0]) {
|
if(conn.handShakeState.load(.monotonic) < data[0]) {
|
||||||
@ -678,7 +678,6 @@ pub const Protocols = struct {
|
|||||||
conn.flush();
|
conn.flush();
|
||||||
conn.mutex.unlock();
|
conn.mutex.unlock();
|
||||||
conn.handShakeState.store(stepServerData, .monotonic);
|
conn.handShakeState.store(stepServerData, .monotonic);
|
||||||
conn.handShakeState.store(stepComplete, .monotonic);
|
|
||||||
main.server.connect(conn.user.?);
|
main.server.connect(conn.user.?);
|
||||||
},
|
},
|
||||||
stepAssets => {
|
stepAssets => {
|
||||||
|
@ -471,6 +471,7 @@ pub fn connectInternal(user: *User) void {
|
|||||||
userMutex.lock();
|
userMutex.lock();
|
||||||
users.append(user);
|
users.append(user);
|
||||||
userMutex.unlock();
|
userMutex.unlock();
|
||||||
|
user.conn.handShakeState.store(main.network.Protocols.handShake.stepComplete, .monotonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn messageFrom(msg: []const u8, source: *User) void { // MARK: message
|
pub fn messageFrom(msg: []const u8, source: *User) void { // MARK: message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user