Skip to content

Commit f3e264b

Browse files
authored
Merge pull request #5101 from stacks-network/fix/event-dispatcher-timeout
Fix event dispatcher stall
2 parents 47a2b14 + 83253a0 commit f3e264b

File tree

13 files changed

+801
-201
lines changed

13 files changed

+801
-201
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stackslib/src/net/api/getstackers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl HttpRequest for GetStackersRequestHandler {
121121
}
122122

123123
fn path_regex(&self) -> Regex {
124-
Regex::new(r#"^/v3/stacker_set/(?P<cycle_num>[0-9]{1,20})$"#).unwrap()
124+
Regex::new(r#"^/v3/stacker_set/(?P<cycle_num>[0-9]{1,10})$"#).unwrap()
125125
}
126126

127127
fn metrics_identifier(&self) -> &str {

stackslib/src/net/atlas/db.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,12 @@ impl AtlasDB {
494494
page_index: u32,
495495
block_id: &StacksBlockId,
496496
) -> Result<Vec<bool>, db_error> {
497-
let min = page_index * AttachmentInstance::ATTACHMENTS_INV_PAGE_SIZE;
498-
let max = min + AttachmentInstance::ATTACHMENTS_INV_PAGE_SIZE;
497+
let min = page_index
498+
.checked_mul(AttachmentInstance::ATTACHMENTS_INV_PAGE_SIZE)
499+
.ok_or(db_error::Overflow)?;
500+
let max = min
501+
.checked_add(AttachmentInstance::ATTACHMENTS_INV_PAGE_SIZE)
502+
.ok_or(db_error::Overflow)?;
499503
let qry = "SELECT attachment_index, is_available FROM attachment_instances WHERE attachment_index >= ?1 AND attachment_index < ?2 AND index_block_hash = ?3 ORDER BY attachment_index ASC";
500504
let args = params![min, max, block_id,];
501505
let rows = query_rows::<(u32, u32), _>(&self.conn, &qry, args)?;

stackslib/src/net/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ impl<P: ProtocolFamily> ConnectionInbox<P> {
971971
// NOTE: it's important that buf not be too big, since up to buf.len()-1 bytes may need
972972
// to be copied if a message boundary isn't aligned with buf (which is usually the
973973
// case).
974-
let mut buf = [0u8; 4096];
974+
let mut buf = [0u8; 65536];
975975
let num_read = match fd.read(&mut buf) {
976976
Ok(0) => {
977977
// remote fd is closed, but do try to consume all remaining bytes in the buffer

stackslib/src/net/http/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ impl FromStr for HttpContentType {
178178
let s = header.to_string().to_lowercase();
179179
if s == "application/octet-stream" {
180180
Ok(HttpContentType::Bytes)
181-
} else if s == "text/plain" {
181+
} else if s == "text/plain" || s.starts_with("text/plain;") {
182182
Ok(HttpContentType::Text)
183-
} else if s == "application/json" {
183+
} else if s == "application/json" || s.starts_with("application/json;") {
184184
Ok(HttpContentType::JSON)
185185
} else {
186-
Err(CodecError::DeserializeError(
187-
"Unsupported HTTP content type".to_string(),
188-
))
186+
Err(CodecError::DeserializeError(format!(
187+
"Unsupported HTTP content type: {header}"
188+
)))
189189
}
190190
}
191191
}

stackslib/src/net/http/response.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl StacksMessageCodec for HttpResponsePreamble {
582582
));
583583
}
584584

585-
if content_type.is_none() || (content_length.is_none() && !chunked_encoding) {
585+
if content_length.is_none() && !chunked_encoding {
586586
return Err(CodecError::DeserializeError(
587587
"Invalid HTTP response: missing Content-Type, Content-Length".to_string(),
588588
));
@@ -593,7 +593,7 @@ impl StacksMessageCodec for HttpResponsePreamble {
593593
status_code: status_code,
594594
reason: reason,
595595
keep_alive: keep_alive,
596-
content_type: content_type.unwrap(),
596+
content_type: content_type.unwrap_or(HttpContentType::Bytes), // per the RFC
597597
content_length: content_length,
598598
headers: headers,
599599
})

stackslib/src/net/http/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ fn test_parse_http_response_preamble_err() {
368368
"Unsupported HTTP content type"),
369369
("HTTP/1.1 200 OK\r\nContent-Length: foo\r\n\r\n",
370370
"Invalid Content-Length"),
371-
("HTTP/1.1 200 OK\r\nContent-Length: 123\r\n\r\n",
372-
"missing Content-Type, Content-Length"),
373371
("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n",
374372
"missing Content-Type, Content-Length"),
375373
("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 123\r\nTransfer-Encoding: chunked\r\n\r\n",

0 commit comments

Comments
 (0)