diff options
author | Eric Blossom | 2010-10-01 00:59:39 -0700 |
---|---|---|
committer | Eric Blossom | 2010-10-01 00:59:39 -0700 |
commit | f989d64d3924ce4b64d67fdb4a1d96963d71bf8b (patch) | |
tree | 64ffe842ffcbdc06638bc55757b0b78d7588d3f3 /vrt/lib | |
parent | 7fad5c4fe2f5ee6b9fa7403fa0b23eb154001798 (diff) | |
download | gnuradio-f989d64d3924ce4b64d67fdb4a1d96963d71bf8b.tar.gz gnuradio-f989d64d3924ce4b64d67fdb4a1d96963d71bf8b.tar.bz2 gnuradio-f989d64d3924ce4b64d67fdb4a1d96963d71bf8b.zip |
Treat failure to allocate big socket buffer as a error
Diffstat (limited to 'vrt/lib')
-rw-r--r-- | vrt/lib/socket_rx_buffer.cc | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/vrt/lib/socket_rx_buffer.cc b/vrt/lib/socket_rx_buffer.cc index 5212af432..203a21295 100644 --- a/vrt/lib/socket_rx_buffer.cc +++ b/vrt/lib/socket_rx_buffer.cc @@ -78,24 +78,47 @@ namespace vrt { // If we've got CAP_NET_ADMIN or root, this will allow the // rmem_max limit to be overridden if (setsockopt(d_fd, SOL_SOCKET, SO_RCVBUFFORCE, - &rcvbuf_size, sizeof(rcvbuf_size)) != 0){ - perror("setsockopt(SO_RCVBUFFORCE)"); + &rcvbuf_size, sizeof(rcvbuf_size)) == 0){ + return true; } else { - fprintf(stderr, "SO_RCVBUFFORCE = %zd\n", buflen); - return true; + if (errno != EPERM) + perror("setsockopt(SO_RCVBUFFORCE)"); } #endif + // Try to set it. On linux trying for too large of a value + // doesn't return an error... if (setsockopt(d_fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf_size, sizeof(rcvbuf_size)) != 0){ perror("setsockopt(SO_RCVBUF)"); + } + + // See how big it actually is + int cursize = 0; + socklen_t optlen; + optlen = sizeof(cursize); + if (getsockopt(d_fd, SOL_SOCKET, SO_RCVBUF, + &cursize, &optlen) != 0){ + perror("getsockopt"); + return false; + } + + // fprintf(stderr, "after: getsockopt(SO_RCVBUF) = %d\n", cursize); + + // If we don't get what we asked for, treat it as an error. + // Otherwise the radio's probably not going to work reliably anyway. + if (cursize < buflen){ fprintf(stderr, - "FIXME: message about configuring /proc/sys/net/core/rmem_max to %zd\n", +"socket_rx_buffer: failed to allocate socket receive buffer of size %d.\n", buflen); - } - else { - fprintf(stderr, "SO_RCVBUF = %zd\n", buflen); + fprintf(stderr, +"To fix this, please increase the maximum allowed using:\n\n"); + fprintf(stderr, + " $ sudo sysctl -w net.core.rmem_max=%d\n\n", buflen); + fprintf(stderr, +"and/or edit /etc/sysctl.conf: net.core.rmem_max=%d\n\n", buflen); + return false; } return true; |