mirror of
https://github.com/bgp/bgpq4.git
synced 2024-05-11 05:55:05 +00:00
sx_maxsockbuf fixed for too big system buffers
This commit is contained in:
4
CHANGES
4
CHANGES
@ -1,3 +1,7 @@
|
||||
0.1.13 (2011-06-14)
|
||||
- Fixed bug in sx_maxsockbuf in rare cases of OS maxsockbuf >2M.
|
||||
Thanks to Andreas Lundin.
|
||||
|
||||
0.1.12 (2010-10-08)
|
||||
- Fixed bug preventing AS262144 (that's AS4.0 in asdot) to expand.
|
||||
Thanks to Sergey Matveychuk
|
||||
|
@ -11,6 +11,10 @@
|
||||
|
||||
#include "sx_report.h"
|
||||
|
||||
#ifndef SX_MAXSOCKBUF_MAX
|
||||
#define SX_MAXSOCKBUF_MAX (2*1024*1024)
|
||||
#endif
|
||||
|
||||
int
|
||||
sx_maxsockbuf(int s, int dir)
|
||||
{
|
||||
@ -39,7 +43,7 @@ sx_maxsockbuf(int s, int dir)
|
||||
if(optval==(hiconf+loconf)/2) break;
|
||||
optval=(hiconf+loconf)/2;
|
||||
};
|
||||
if(optval>(2*1024*1024)) {
|
||||
if(optval>SX_MAXSOCKBUF_MAX) {
|
||||
if(phase==0) {
|
||||
phase=1; optval>>=1; continue;
|
||||
} else break;
|
||||
@ -59,14 +63,16 @@ sx_maxsockbuf(int s, int dir)
|
||||
if(getsockopt(s,SOL_SOCKET,dir,(void*)&voptval,&voptlen)==-1) {
|
||||
sx_report(SX_ERROR,"getsockopt failed: %s\n", strerror(errno));
|
||||
return -1;
|
||||
} else {
|
||||
if(voptval<optval) {
|
||||
if(phase==0) {
|
||||
phase=1; optval>>=1; continue;
|
||||
} else if(phase==1) {
|
||||
phase=2; optval-=2048; continue;
|
||||
} else break;
|
||||
};
|
||||
} else if(voptval<optval) {
|
||||
if(phase==0) {
|
||||
phase=1; optval>>=1; continue;
|
||||
} else if(phase==1) {
|
||||
phase=2; optval-=2048; continue;
|
||||
} else break;
|
||||
} else if(optval>=SX_MAXSOCKBUF_MAX) {
|
||||
/* ... and getsockopt not failed and voptval>=optval. Do not allow
|
||||
* to increase sockbuf too much even in case OS permits it */
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user