| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
package tcpip |
| 16 |
|
| 17 |
import ( |
| 18 |
"sync/atomic" |
| 19 |
|
| 20 |
"inet.af/netstack/atomicbitops" |
| 21 |
"inet.af/netstack/sync" |
| 22 |
) |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
type SocketOptionsHandler interface { |
| 28 |
|
| 29 |
OnReuseAddressSet(v bool) |
| 30 |
|
| 31 |
|
| 32 |
OnReusePortSet(v bool) |
| 33 |
|
| 34 |
|
| 35 |
OnKeepAliveSet(v bool) |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
OnDelayOptionSet(v bool) |
| 40 |
|
| 41 |
|
| 42 |
OnCorkOptionSet(v bool) |
| 43 |
|
| 44 |
|
| 45 |
LastError() Error |
| 46 |
|
| 47 |
|
| 48 |
UpdateLastError(err Error) |
| 49 |
|
| 50 |
|
| 51 |
HasNIC(v int32) bool |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
OnSetSendBufferSize(v int64) (newSz int64) |
| 57 |
|
| 58 |
|
| 59 |
OnSetReceiveBufferSize(v, oldSz int64) (newSz int64) |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
WakeupWriters() |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
type DefaultSocketOptionsHandler struct{} |
| 70 |
|
| 71 |
var _ SocketOptionsHandler = (*DefaultSocketOptionsHandler)(nil) |
| 72 |
|
| 73 |
|
| 74 |
func (*DefaultSocketOptionsHandler) OnReuseAddressSet(bool) {} |
| 75 |
|
| 76 |
|
| 77 |
func (*DefaultSocketOptionsHandler) OnReusePortSet(bool) {} |
| 78 |
|
| 79 |
|
| 80 |
func (*DefaultSocketOptionsHandler) OnKeepAliveSet(bool) {} |
| 81 |
|
| 82 |
|
| 83 |
func (*DefaultSocketOptionsHandler) OnDelayOptionSet(bool) {} |
| 84 |
|
| 85 |
|
| 86 |
func (*DefaultSocketOptionsHandler) OnCorkOptionSet(bool) {} |
| 87 |
|
| 88 |
|
| 89 |
func (*DefaultSocketOptionsHandler) LastError() Error { |
| 90 |
return nil |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
func (*DefaultSocketOptionsHandler) UpdateLastError(Error) {} |
| 95 |
|
| 96 |
|
| 97 |
func (*DefaultSocketOptionsHandler) HasNIC(int32) bool { |
| 98 |
return false |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
func (*DefaultSocketOptionsHandler) OnSetSendBufferSize(v int64) (newSz int64) { |
| 103 |
return v |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
func (*DefaultSocketOptionsHandler) WakeupWriters() {} |
| 108 |
|
| 109 |
|
| 110 |
func (*DefaultSocketOptionsHandler) OnSetReceiveBufferSize(v, oldSz int64) (newSz int64) { |
| 111 |
return v |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
type StackHandler interface { |
| 117 |
|
| 118 |
Option(option interface{}) Error |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
TransportProtocolOption(proto TransportProtocolNumber, option GettableTransportProtocolOption) Error |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
type SocketOptions struct { |
| 130 |
handler SocketOptionsHandler |
| 131 |
|
| 132 |
|
| 133 |
stackHandler StackHandler `state:"manual"` |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
broadcastEnabled uint32 |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
passCredEnabled uint32 |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
noChecksumEnabled uint32 |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
reuseAddressEnabled uint32 |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
reusePortEnabled uint32 |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
keepAliveEnabled uint32 |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
multicastLoopEnabled uint32 |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
receiveTOSEnabled uint32 |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
receiveTClassEnabled uint32 |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
receivePacketInfoEnabled uint32 |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
receiveIPv6PacketInfoEnabled uint32 |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
hdrIncludedEnabled uint32 |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
v6OnlyEnabled uint32 |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
quickAckEnabled uint32 |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
delayOptionEnabled uint32 |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
corkOptionEnabled uint32 |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
receiveOriginalDstAddress uint32 |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
recvErrEnabled uint32 |
| 210 |
|
| 211 |
|
| 212 |
errQueueMu sync.Mutex `state:"nosave"` |
| 213 |
errQueue sockErrorList |
| 214 |
|
| 215 |
|
| 216 |
bindToDevice int32 |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
getSendBufferLimits GetSendBufferLimits `state:"manual"` |
| 222 |
|
| 223 |
|
| 224 |
sendBufferSize atomicbitops.AlignedAtomicInt64 |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
getReceiveBufferLimits GetReceiveBufferLimits `state:"manual"` |
| 230 |
|
| 231 |
|
| 232 |
receiveBufferSize atomicbitops.AlignedAtomicInt64 |
| 233 |
|
| 234 |
|
| 235 |
mu sync.Mutex `state:"nosave"` |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
linger LingerOption |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
func (so *SocketOptions) InitHandler(handler SocketOptionsHandler, stack StackHandler, getSendBufferLimits GetSendBufferLimits, getReceiveBufferLimits GetReceiveBufferLimits) { |
| 245 |
so.handler = handler |
| 246 |
so.stackHandler = stack |
| 247 |
so.getSendBufferLimits = getSendBufferLimits |
| 248 |
so.getReceiveBufferLimits = getReceiveBufferLimits |
| 249 |
} |
| 250 |
|
| 251 |
func storeAtomicBool(addr *uint32, v bool) { |
| 252 |
var val uint32 |
| 253 |
if v { |
| 254 |
val = 1 |
| 255 |
} |
| 256 |
atomic.StoreUint32(addr, val) |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
func (so *SocketOptions) SetLastError(err Error) { |
| 261 |
so.handler.UpdateLastError(err) |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
func (so *SocketOptions) GetBroadcast() bool { |
| 266 |
return atomic.LoadUint32(&so.broadcastEnabled) != 0 |
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
func (so *SocketOptions) SetBroadcast(v bool) { |
| 271 |
storeAtomicBool(&so.broadcastEnabled, v) |
| 272 |
} |
| 273 |
|
| 274 |
|
| 275 |
func (so *SocketOptions) GetPassCred() bool { |
| 276 |
return atomic.LoadUint32(&so.passCredEnabled) != 0 |
| 277 |
} |
| 278 |
|
| 279 |
|
| 280 |
func (so *SocketOptions) SetPassCred(v bool) { |
| 281 |
storeAtomicBool(&so.passCredEnabled, v) |
| 282 |
} |
| 283 |
|
| 284 |
|
| 285 |
func (so *SocketOptions) GetNoChecksum() bool { |
| 286 |
return atomic.LoadUint32(&so.noChecksumEnabled) != 0 |
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
func (so *SocketOptions) SetNoChecksum(v bool) { |
| 291 |
storeAtomicBool(&so.noChecksumEnabled, v) |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
func (so *SocketOptions) GetReuseAddress() bool { |
| 296 |
return atomic.LoadUint32(&so.reuseAddressEnabled) != 0 |
| 297 |
} |
| 298 |
|
| 299 |
|
| 300 |
func (so *SocketOptions) SetReuseAddress(v bool) { |
| 301 |
storeAtomicBool(&so.reuseAddressEnabled, v) |
| 302 |
so.handler.OnReuseAddressSet(v) |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
func (so *SocketOptions) GetReusePort() bool { |
| 307 |
return atomic.LoadUint32(&so.reusePortEnabled) != 0 |
| 308 |
} |
| 309 |
|
| 310 |
|
| 311 |
func (so *SocketOptions) SetReusePort(v bool) { |
| 312 |
storeAtomicBool(&so.reusePortEnabled, v) |
| 313 |
so.handler.OnReusePortSet(v) |
| 314 |
} |
| 315 |
|
| 316 |
|
| 317 |
func (so *SocketOptions) GetKeepAlive() bool { |
| 318 |
return atomic.LoadUint32(&so.keepAliveEnabled) != 0 |
| 319 |
} |
| 320 |
|
| 321 |
|
| 322 |
func (so *SocketOptions) SetKeepAlive(v bool) { |
| 323 |
storeAtomicBool(&so.keepAliveEnabled, v) |
| 324 |
so.handler.OnKeepAliveSet(v) |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
func (so *SocketOptions) GetMulticastLoop() bool { |
| 329 |
return atomic.LoadUint32(&so.multicastLoopEnabled) != 0 |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
func (so *SocketOptions) SetMulticastLoop(v bool) { |
| 334 |
storeAtomicBool(&so.multicastLoopEnabled, v) |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
func (so *SocketOptions) GetReceiveTOS() bool { |
| 339 |
return atomic.LoadUint32(&so.receiveTOSEnabled) != 0 |
| 340 |
} |
| 341 |
|
| 342 |
|
| 343 |
func (so *SocketOptions) SetReceiveTOS(v bool) { |
| 344 |
storeAtomicBool(&so.receiveTOSEnabled, v) |
| 345 |
} |
| 346 |
|
| 347 |
|
| 348 |
func (so *SocketOptions) GetReceiveTClass() bool { |
| 349 |
return atomic.LoadUint32(&so.receiveTClassEnabled) != 0 |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
func (so *SocketOptions) SetReceiveTClass(v bool) { |
| 354 |
storeAtomicBool(&so.receiveTClassEnabled, v) |
| 355 |
} |
| 356 |
|
| 357 |
|
| 358 |
func (so *SocketOptions) GetReceivePacketInfo() bool { |
| 359 |
return atomic.LoadUint32(&so.receivePacketInfoEnabled) != 0 |
| 360 |
} |
| 361 |
|
| 362 |
|
| 363 |
func (so *SocketOptions) SetReceivePacketInfo(v bool) { |
| 364 |
storeAtomicBool(&so.receivePacketInfoEnabled, v) |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
func (so *SocketOptions) GetIPv6ReceivePacketInfo() bool { |
| 369 |
return atomic.LoadUint32(&so.receiveIPv6PacketInfoEnabled) != 0 |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
func (so *SocketOptions) SetIPv6ReceivePacketInfo(v bool) { |
| 374 |
storeAtomicBool(&so.receiveIPv6PacketInfoEnabled, v) |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
func (so *SocketOptions) GetHeaderIncluded() bool { |
| 379 |
return atomic.LoadUint32(&so.hdrIncludedEnabled) != 0 |
| 380 |
} |
| 381 |
|
| 382 |
|
| 383 |
func (so *SocketOptions) SetHeaderIncluded(v bool) { |
| 384 |
storeAtomicBool(&so.hdrIncludedEnabled, v) |
| 385 |
} |
| 386 |
|
| 387 |
|
| 388 |
func (so *SocketOptions) GetV6Only() bool { |
| 389 |
return atomic.LoadUint32(&so.v6OnlyEnabled) != 0 |
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
func (so *SocketOptions) SetV6Only(v bool) { |
| 396 |
storeAtomicBool(&so.v6OnlyEnabled, v) |
| 397 |
} |
| 398 |
|
| 399 |
|
| 400 |
func (so *SocketOptions) GetQuickAck() bool { |
| 401 |
return atomic.LoadUint32(&so.quickAckEnabled) != 0 |
| 402 |
} |
| 403 |
|
| 404 |
|
| 405 |
func (so *SocketOptions) SetQuickAck(v bool) { |
| 406 |
storeAtomicBool(&so.quickAckEnabled, v) |
| 407 |
} |
| 408 |
|
| 409 |
|
| 410 |
func (so *SocketOptions) GetDelayOption() bool { |
| 411 |
return atomic.LoadUint32(&so.delayOptionEnabled) != 0 |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
func (so *SocketOptions) SetDelayOption(v bool) { |
| 416 |
storeAtomicBool(&so.delayOptionEnabled, v) |
| 417 |
so.handler.OnDelayOptionSet(v) |
| 418 |
} |
| 419 |
|
| 420 |
|
| 421 |
func (so *SocketOptions) GetCorkOption() bool { |
| 422 |
return atomic.LoadUint32(&so.corkOptionEnabled) != 0 |
| 423 |
} |
| 424 |
|
| 425 |
|
| 426 |
func (so *SocketOptions) SetCorkOption(v bool) { |
| 427 |
storeAtomicBool(&so.corkOptionEnabled, v) |
| 428 |
so.handler.OnCorkOptionSet(v) |
| 429 |
} |
| 430 |
|
| 431 |
|
| 432 |
func (so *SocketOptions) GetReceiveOriginalDstAddress() bool { |
| 433 |
return atomic.LoadUint32(&so.receiveOriginalDstAddress) != 0 |
| 434 |
} |
| 435 |
|
| 436 |
|
| 437 |
func (so *SocketOptions) SetReceiveOriginalDstAddress(v bool) { |
| 438 |
storeAtomicBool(&so.receiveOriginalDstAddress, v) |
| 439 |
} |
| 440 |
|
| 441 |
|
| 442 |
func (so *SocketOptions) GetRecvError() bool { |
| 443 |
return atomic.LoadUint32(&so.recvErrEnabled) != 0 |
| 444 |
} |
| 445 |
|
| 446 |
|
| 447 |
func (so *SocketOptions) SetRecvError(v bool) { |
| 448 |
storeAtomicBool(&so.recvErrEnabled, v) |
| 449 |
if !v { |
| 450 |
so.pruneErrQueue() |
| 451 |
} |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
func (so *SocketOptions) GetLastError() Error { |
| 456 |
return so.handler.LastError() |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
func (*SocketOptions) GetOutOfBandInline() bool { |
| 461 |
return true |
| 462 |
} |
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
func (*SocketOptions) SetOutOfBandInline(bool) {} |
| 467 |
|
| 468 |
|
| 469 |
func (so *SocketOptions) GetLinger() LingerOption { |
| 470 |
so.mu.Lock() |
| 471 |
linger := so.linger |
| 472 |
so.mu.Unlock() |
| 473 |
return linger |
| 474 |
} |
| 475 |
|
| 476 |
|
| 477 |
func (so *SocketOptions) SetLinger(linger LingerOption) { |
| 478 |
so.mu.Lock() |
| 479 |
so.linger = linger |
| 480 |
so.mu.Unlock() |
| 481 |
} |
| 482 |
|
| 483 |
|
| 484 |
type SockErrOrigin uint8 |
| 485 |
|
| 486 |
const ( |
| 487 |
|
| 488 |
SockExtErrorOriginNone SockErrOrigin = iota |
| 489 |
|
| 490 |
|
| 491 |
SockExtErrorOriginLocal |
| 492 |
|
| 493 |
|
| 494 |
SockExtErrorOriginICMP |
| 495 |
|
| 496 |
|
| 497 |
SockExtErrorOriginICMP6 |
| 498 |
) |
| 499 |
|
| 500 |
|
| 501 |
func (origin SockErrOrigin) IsICMPErr() bool { |
| 502 |
return origin == SockExtErrorOriginICMP || origin == SockExtErrorOriginICMP6 |
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
type SockErrorCause interface { |
| 507 |
|
| 508 |
Origin() SockErrOrigin |
| 509 |
|
| 510 |
|
| 511 |
Type() uint8 |
| 512 |
|
| 513 |
|
| 514 |
Code() uint8 |
| 515 |
|
| 516 |
|
| 517 |
Info() uint32 |
| 518 |
} |
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
type LocalSockError struct { |
| 524 |
info uint32 |
| 525 |
} |
| 526 |
|
| 527 |
|
| 528 |
func (*LocalSockError) Origin() SockErrOrigin { |
| 529 |
return SockExtErrorOriginLocal |
| 530 |
} |
| 531 |
|
| 532 |
|
| 533 |
func (*LocalSockError) Type() uint8 { |
| 534 |
return 0 |
| 535 |
} |
| 536 |
|
| 537 |
|
| 538 |
func (*LocalSockError) Code() uint8 { |
| 539 |
return 0 |
| 540 |
} |
| 541 |
|
| 542 |
|
| 543 |
func (l *LocalSockError) Info() uint32 { |
| 544 |
return l.info |
| 545 |
} |
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
type SockError struct { |
| 551 |
sockErrorEntry |
| 552 |
|
| 553 |
|
| 554 |
Err Error |
| 555 |
|
| 556 |
Cause SockErrorCause |
| 557 |
|
| 558 |
|
| 559 |
Payload []byte |
| 560 |
|
| 561 |
Dst FullAddress |
| 562 |
|
| 563 |
Offender FullAddress |
| 564 |
|
| 565 |
NetProto NetworkProtocolNumber |
| 566 |
} |
| 567 |
|
| 568 |
|
| 569 |
func (so *SocketOptions) pruneErrQueue() { |
| 570 |
so.errQueueMu.Lock() |
| 571 |
so.errQueue.Reset() |
| 572 |
so.errQueueMu.Unlock() |
| 573 |
} |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
func (so *SocketOptions) DequeueErr() *SockError { |
| 578 |
so.errQueueMu.Lock() |
| 579 |
defer so.errQueueMu.Unlock() |
| 580 |
|
| 581 |
err := so.errQueue.Front() |
| 582 |
if err != nil { |
| 583 |
so.errQueue.Remove(err) |
| 584 |
} |
| 585 |
return err |
| 586 |
} |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
func (so *SocketOptions) PeekErr() *SockError { |
| 591 |
so.errQueueMu.Lock() |
| 592 |
defer so.errQueueMu.Unlock() |
| 593 |
return so.errQueue.Front() |
| 594 |
} |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
func (so *SocketOptions) QueueErr(err *SockError) { |
| 600 |
so.errQueueMu.Lock() |
| 601 |
defer so.errQueueMu.Unlock() |
| 602 |
so.errQueue.PushBack(err) |
| 603 |
} |
| 604 |
|
| 605 |
|
| 606 |
func (so *SocketOptions) QueueLocalErr(err Error, net NetworkProtocolNumber, info uint32, dst FullAddress, payload []byte) { |
| 607 |
so.QueueErr(&SockError{ |
| 608 |
Err: err, |
| 609 |
Cause: &LocalSockError{info: info}, |
| 610 |
Payload: payload, |
| 611 |
Dst: dst, |
| 612 |
NetProto: net, |
| 613 |
}) |
| 614 |
} |
| 615 |
|
| 616 |
|
| 617 |
func (so *SocketOptions) GetBindToDevice() int32 { |
| 618 |
return atomic.LoadInt32(&so.bindToDevice) |
| 619 |
} |
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
func (so *SocketOptions) SetBindToDevice(bindToDevice int32) Error { |
| 624 |
if bindToDevice != 0 && !so.handler.HasNIC(bindToDevice) { |
| 625 |
return &ErrUnknownDevice{} |
| 626 |
} |
| 627 |
|
| 628 |
atomic.StoreInt32(&so.bindToDevice, bindToDevice) |
| 629 |
return nil |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
func (so *SocketOptions) GetSendBufferSize() int64 { |
| 634 |
return so.sendBufferSize.Load() |
| 635 |
} |
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
func (so *SocketOptions) SendBufferLimits() (min, max int64) { |
| 640 |
limits := so.getSendBufferLimits(so.stackHandler) |
| 641 |
return int64(limits.Min), int64(limits.Max) |
| 642 |
} |
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
func (so *SocketOptions) SetSendBufferSize(sendBufferSize int64, notify bool) { |
| 647 |
if notify { |
| 648 |
sendBufferSize = so.handler.OnSetSendBufferSize(sendBufferSize) |
| 649 |
} |
| 650 |
so.sendBufferSize.Store(sendBufferSize) |
| 651 |
if notify { |
| 652 |
so.handler.WakeupWriters() |
| 653 |
} |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
func (so *SocketOptions) GetReceiveBufferSize() int64 { |
| 658 |
return so.receiveBufferSize.Load() |
| 659 |
} |
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
func (so *SocketOptions) ReceiveBufferLimits() (min, max int64) { |
| 664 |
limits := so.getReceiveBufferLimits(so.stackHandler) |
| 665 |
return int64(limits.Min), int64(limits.Max) |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
func (so *SocketOptions) SetReceiveBufferSize(receiveBufferSize int64, notify bool) { |
| 671 |
if notify { |
| 672 |
oldSz := so.receiveBufferSize.Load() |
| 673 |
receiveBufferSize = so.handler.OnSetReceiveBufferSize(receiveBufferSize, oldSz) |
| 674 |
} |
| 675 |
so.receiveBufferSize.Store(receiveBufferSize) |
| 676 |
} |