Make sctp buffers big enough for images
We had multiple problems.
1) kernel buffers were too small so the kernel was delivering partial
packets. Fix was to update the rootfs to increase the buffer size
and check the parameter. Secondary fix was to CHECK that received
packets were the size advertized.
2) Client wasn't configuring it's buffers to be the right size.
Configured the socket to make it big enough.
Change-Id: I276e698943aa5714ff2ca8e1ac73d6975d219eb9
diff --git a/aos/network/sctp_client.h b/aos/network/sctp_client.h
index 5b6df3b..6b84638 100644
--- a/aos/network/sctp_client.h
+++ b/aos/network/sctp_client.h
@@ -43,7 +43,19 @@
void LogSctpStatus(sctp_assoc_t assoc_id);
- void set_max_size(size_t max_size) { max_size_ = max_size; }
+ void SetMaxSize(size_t max_size) {
+ max_size_ = max_size;
+ // Have the kernel give us a factor of 10 more. This lets us have more than
+ // one full sized packet in flight.
+ max_size = max_size * 10;
+
+ CHECK_GE(ReadRMemMax(), max_size);
+ CHECK_GE(ReadWMemMax(), max_size);
+ PCHECK(setsockopt(fd_, SOL_SOCKET, SO_RCVBUF, &max_size,
+ sizeof(max_size)) == 0);
+ PCHECK(setsockopt(fd_, SOL_SOCKET, SO_SNDBUF, &max_size,
+ sizeof(max_size)) == 0);
+ }
private:
struct sockaddr_storage sockaddr_remote_;