[personal profile] sassa_nf
ok, connect to a socket (td-agent here, but it probably doesn't matter):

irb(main):023:0* sock = TCPSocket.new('localhost', 8124)
=> #
irb(main):024:0> sock.write('doh')
=> 3
irb(main):025:0> 
[1]+  Stopped                 irb

# service td-agent restart
td-agent stop/waiting
td-agent start/running, process 18296

# fg
irb
irb(main):031:0> 
irb(main):032:0* sock.write('doh')
=> 3
irb(main):033:0> sock.write('doh') # yes, we've restarted the server, so connection eventually fails
Errno::EPIPE: Broken pipe
	from (irb):33:in `write'
	from (irb):33
	from /usr/bin/irb:11:in `
' irb(main):034:0> sock.write('doh') Errno::EPIPE: Broken pipe from (irb):34:in `write' from (irb):34 from /usr/bin/irb:11:in `
'


But what if...
irb(main):001:0> require 'socket'
=> true
irb(main):002:0> sock = TCPSocket.new('localhost', 8124)
=> #
irb(main):003:0> sock.write('doh')
=> 3
irb(main):004:0> 
[1]+  Stopped                 irb
# service td-agent restart
td-agent stop/waiting
td-agent start/running, process 13180
# fg
irb
sleep 60
sleep 60

=> 60


You'd expect the socket to be closed, or eventually error on write?


irb(main):005:0>
irb(main):006:0* sock.write('doh')
=> 3
irb(main):007:0> sock.write('doh')
=> 3
irb(main):008:0> sock.write('doh')
=> 3
irb(main):009:0> sock.write('doh')
=> 3
irb(main):010:0> sock.write('doh')
=> 3
irb(main):011:0>
[1]+ Stopped irb
# netstat -nap | grep 59172
tcp 1 15 127.0.0.1:59172 127.0.0.1:8124 CLOSE_WAIT 12727/irb


But we have 15 bytes (5 * 'doh') queued up instead.

# fg
irb
^[[A
sock.write('doh')
=> 3
irb(main):012:0> sock.write('doh')
=> 3
irb(main):013:0> sock.write('doh')
=> 3
irb(main):014:0> sock.write('doh')
=> 3
irb(main):015:0> sock.write('doh')
=> 3
irb(main):016:0> 
[1]+  Stopped                 irb
# netstat -nap | grep 59172
tcp        1     30 127.0.0.1:59172         127.0.0.1:8124          CLOSE_WAIT  12727/irb       
# fg
irb
^[[A
sock.write('doh')
=> 3
irb(main):017:0> sock.write('doh' * 30000)
=> 90000
irb(main):018:0> sock.write('doh' * 30000)
=> 90000
irb(main):019:0> sock.write('doh' * 30000)
=> 90000
irb(main):020:0> sock.write('doh' * 30000000)
^Z
[1]+  Stopped                 irb
# netstat -nap | grep 59172
tcp        1 2531843 127.0.0.1:59172         127.0.0.1:8124          CLOSE_WAIT  12727/irb       
# fg
irb

^Z
[1]+  Stopped                 irb
# netstat -nap | grep 59172
tcp        1 2531843 127.0.0.1:59172         127.0.0.1:8124          CLOSE_WAIT  12727/irb       
# netstat -nap | grep 59172
tcp        1 2531843 127.0.0.1:59172         127.0.0.1:8124          CLOSE_WAIT  12727/irb       
# fg
irb

(...chirp...chirp...)

Date: 2019-01-17 02:00 pm (UTC)
henry_flower: A melancholy wolf (Default)
From: [personal profile] henry_flower
$ alias s='ss -nap | grep 9000 | tr -s " "'
$ 
$ ruby -run -ehttpd . -p9000 &
[1] 70344
$ [2019-01-17 15:52:46] INFO  WEBrick 1.4.2
[2019-01-17 15:52:46] INFO  ruby 2.5.1 (2018-03-29) [x86_64-linux]
[2019-01-17 15:52:46] INFO  WEBrick::HTTPServer#start: pid=70344 port=9000

$ s
tcp LISTEN 0 128 0.0.0.0:9000 0.0.0.0:* users:(("ruby",pid=70344,fd=8)) 
tcp LISTEN 0 128 [::]:9000 [::]:* users:(("ruby",pid=70344,fd=9)) 
$ 
$ irb
2.5.1 :001 > require 'socket'
true
2.5.1 :002 > sock = TCPSocket.new 'localhost', 9000
#<TCPSocket:fd 10, AF_INET6, ::1, 36948>
2.5.1 :003 > sock.write 'doh'
3
2.5.1 :004 > 
[2]+  Stopped                 irb
$ 
$ s
tcp LISTEN 0 128 0.0.0.0:9000 0.0.0.0:* users:(("ruby",pid=70344,fd=8)) 
tcp LISTEN 0 128 [::]:9000 [::]:* users:(("ruby",pid=70344,fd=9)) 
tcp ESTAB 0 0 [::1]:36948 [::1]:9000 users:(("ruby",pid=70349,fd=10)) 
tcp ESTAB 0 0 [::1]:9000 [::1]:36948 users:(("ruby",pid=70344,fd=12)) 
$ 
$ kill 70344
[2019-01-17 15:53:55] INFO  going to shutdown ...
[2019-01-17 15:53:55] INFO  WEBrick::HTTPServer#start done.
$ 
[1]-  Done                    ruby -run -ehttpd . -p9000
$ 
$ s
tcp CLOSE-WAIT 1 0 [::1]:36948 [::1]:9000 users:(("ruby",pid=70349,fd=10)) 
tcp FIN-WAIT-2 0 0 [::1]:9000 [::1]:36948 
$ 
$ ruby -run -ehttpd . -p9000 &
[3] 70363
$ [2019-01-17 15:54:14] INFO  WEBrick 1.4.2
[2019-01-17 15:54:14] INFO  ruby 2.5.1 (2018-03-29) [x86_64-linux]
[2019-01-17 15:54:14] INFO  WEBrick::HTTPServer#start: pid=70363 port=9000

$ s
tcp LISTEN 0 128 0.0.0.0:9000 0.0.0.0:* users:(("ruby",pid=70363,fd=8)) 
tcp LISTEN 0 128 [::]:9000 [::]:* users:(("ruby",pid=70363,fd=9)) 
tcp CLOSE-WAIT 1 0 [::1]:36948 [::1]:9000 users:(("ruby",pid=70349,fd=10)) 
tcp FIN-WAIT-2 0 0 [::1]:9000 [::1]:36948 
$ 
$ fg
irb
sleep 60
sleep 60
60
2.5.1 :005 > sock.write 'doh'
3
2.5.1 :006 > sock.write 'doh'
Traceback (most recent call last):
        3: from /home/alex/.rvm/rubies/ruby-2.5.1/bin/irb:11:in `<main>'
        2: from (irb):6
        1: from (irb):6:in `write'
Errno::EPIPE (Broken pipe)
2.5.1 :007 > 
$ s
tcp LISTEN 0 128 0.0.0.0:9000 0.0.0.0:* users:(("ruby",pid=70363,fd=8)) 
tcp LISTEN 0 128 [::]:9000 [::]:* users:(("ruby",pid=70363,fd=9)) 

Edited Date: 2019-01-17 02:08 pm (UTC)

Date: 2019-01-22 07:00 am (UTC)
henry_flower: A melancholy wolf (Default)
From: [personal profile] henry_flower

до речі,

Version Latest  release date    End of support  End of security maintenance
2.1     2.1.10  2013-12-25      2016-03-30      2017-03-31
2.2     2.2.10  2014-12-25      2017-03-28      2018-03-31
2.3     2.3.8   2015-12-25      2018-06-20      2019-03-31
2.4     2.4.5   2016-12-25      TBA             TBA
2.5     2.5.3   2017-12-25      TBA             TBA
2.6     2.6.0   2018-12-25      TBA             TBA
3.0             2020            TBA             TBA

(особливо правий стовпець)

та https://www.ruby-lang.org/en/security/

I'm just sayin'

Edited Date: 2019-01-22 07:01 am (UTC)

Date: 2019-01-21 03:37 pm (UTC)
henry_flower: A melancholy wolf (Default)
From: [personal profile] henry_flower

$ uname -a
Linux fedora.9bf016 4.19.15-300.fc29.x86_64 #1 SMP Mon Jan 14 16:32:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -d
Description:    Fedora release 29 (Twenty Nine)

Date: 2019-01-22 06:38 am (UTC)
henry_flower: A melancholy wolf (Default)
From: [personal profile] henry_flower

хех

а це цікаво, дякую!

Profile

sassa_nf

January 2026

S M T W T F S
    123
45678910
111213141516 17
18192021222324
25262728293031

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 23rd, 2026 07:21 pm
Powered by Dreamwidth Studios