Skip to content

Commit 74df8f9

Browse files
committed
Use proper atomic ordering in HTTPCon._state
Signed-off-by: Wolfgang E. Sanyer <wolfgangesanyer@gmail.com>
1 parent 58d9ec6 commit 74df8f9

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/worker.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ pub fn NonBlocking(comptime S: type, comptime WSH: type) type {
570570
.signal => self.processSignal(&closed_conn),
571571
.recv => |conn| switch (conn.protocol) {
572572
.http => |http_conn| {
573-
switch (http_conn._state.load(.monotonic)) {
573+
switch (http_conn._state.load(.acquire)) {
574574
.request, .keepalive => {},
575575
.active, .handover => {
576576
// we need to finish whatever we're doing
@@ -628,14 +628,14 @@ pub fn NonBlocking(comptime S: type, comptime WSH: type) type {
628628
http_conn._mut.lock();
629629
defer http_conn._mut.unlock();
630630

631-
switch (http_conn._state.load(.monotonic)) {
631+
switch (http_conn._state.load(.acquire)) {
632632
.active => self.active_list.remove(conn),
633633
.keepalive => self.keepalive_list.remove(conn),
634634
.request => self.request_list.remove(conn),
635635
.handover => self.handover_list.remove(conn),
636636
}
637637

638-
http_conn._state.store(new_state, .monotonic);
638+
http_conn._state.store(new_state, .release);
639639

640640
switch (new_state) {
641641
.active => self.active_list.insert(conn),
@@ -688,7 +688,7 @@ pub fn NonBlocking(comptime S: type, comptime WSH: type) type {
688688

689689
const http_conn = try self.http_conn_pool.acquire();
690690
http_conn.request_count = 1;
691-
http_conn._state.store(.request, .monotonic);
691+
http_conn._state.store(.request, .release);
692692
http_conn.handover = .unknown;
693693
http_conn._io_mode = .nonblocking;
694694
http_conn.address = address;
@@ -845,7 +845,7 @@ pub fn NonBlocking(comptime S: type, comptime WSH: type) type {
845845

846846
fn disown(self: *Self, conn: *Conn(WSH)) void {
847847
const http_conn = conn.protocol.http;
848-
switch (http_conn._state.load(.monotonic)) {
848+
switch (http_conn._state.load(.acquire)) {
849849
.request => self.request_list.remove(conn),
850850
.handover => self.handover_list.remove(conn),
851851
.keepalive => self.keepalive_list.remove(conn),

0 commit comments

Comments
 (0)