mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 23:24:09 +00:00
endpoint example: saner count on add
This commit is contained in:
parent
b265b4315d
commit
5b105f508e
1 changed files with 2 additions and 3 deletions
|
@ -49,12 +49,11 @@ pub fn addByName(self: *Self, first: ?[]const u8, last: ?[]const u8) !usize {
|
|||
// We lock only on insertion, deletion, and listing
|
||||
self.lock.lock();
|
||||
defer self.lock.unlock();
|
||||
self.count = self.count + 1;
|
||||
user.id = self.count;
|
||||
user.id = self.count + 1;
|
||||
if (self.users.put(user.id, user)) {
|
||||
self.count += 1;
|
||||
return user.id;
|
||||
} else |err| {
|
||||
self.count -= 1;
|
||||
std.debug.print("addByName error: {}\n", .{err});
|
||||
// make sure we pass on the error
|
||||
return err;
|
||||
|
|
Loading…
Add table
Reference in a new issue