nickva commented on PR #4729:
URL: https://github.com/apache/couchdb/pull/4729#issuecomment-1688590578

   I managed to find a way to seemingly detect the connection state change 
after the local client (curl) disconnects by querying the equivalent of 
`getsockopt(fd(), IPPROTO_TCP, TCP_CONNECTION_INFO, &info, &info_size)`
   
   ```
   ([email protected])22> rp(inet:getopts(#Port<0.24>, [{raw, 6, 262, 1000}])).
   {ok,[{raw,6,262,
             <<4,6,6,0,7,0,0,0,0,0,0,0,0,0,0,0,204,63,0,0,0,192,255,
               63,18,0,2,0,0,57,6,0,0,0,0,0,88,58,6,0,1,0,0,0,1,0,0,
               0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,177,1,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,148,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>}]}
   ok
   ```
   
   Ctrl+C...
   
   ```
   ([email protected])24> inet:info(#Port<0.24>).
   #{counters =>
         #{recv_avg => 24,recv_cnt => 6,recv_dvi => 10,recv_max => 51,
           recv_oct => 148,send_avg => 216,send_cnt => 2,
           send_max => 427,send_oct => 433,send_pend => 0},
     input => 0,
     links => [<0.12859.0>],
     memory => 40,monitors => [],output => 433,
     owner => <0.12859.0>,
     states => [connected,open]}
   
   ([email protected])25> rp(inet:getopts(#Port<0.24>, [{raw, 6, 262, 1000}])).
   {ok,[{raw,6,262,
             <<5,6,6,0,7,0,0,0,0,0,0,0,0,0,0,0,204,63,0,0,0,192,255,
               63,18,0,2,0,0,57,6,0,0,0,0,0,88,58,6,0,59,58,0,0,1,0,
               0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,177,1,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,148,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>}]}
   ok
   ```
   
   Looks like Linux has a similar facility so there is some hope, though it 
does look very ugly


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to