@@ -62,12 +62,12 @@ func (rw *remoteUnit) connectToRemote(ctx context.Context) (net.Conn, *bufio.Rea
6262 ctxChild , _ := context .WithTimeout (ctx , 5 * time .Second )
6363 hello , err := utils .ReadStringContext (ctxChild , reader , '\n' )
6464 if err != nil {
65- conn .CloseConnection ()
65+ _ = conn .Close ()
6666
6767 return nil , nil , err
6868 }
6969 if ! strings .Contains (hello , red .RemoteNode ) {
70- conn .CloseConnection ()
70+ _ = conn .Close ()
7171
7272 return nil , nil , fmt .Errorf ("while expecting node ID %s, got message: %s" , red .RemoteNode ,
7373 strings .TrimRight (hello , "\n " ))
@@ -144,7 +144,7 @@ func (rw *remoteUnit) getConnectionAndRun(ctx context.Context, firstTimeSync boo
144144
145145// startRemoteUnit makes a single attempt to start a remote unit.
146146func (rw * remoteUnit ) startRemoteUnit (ctx context.Context , conn net.Conn , reader * bufio.Reader ) error {
147- defer conn .( interface { CloseConnection () error }). CloseConnection ()
147+ defer conn .Close ()
148148 red := rw .UnredactedStatus ().ExtraData .(* remoteExtraData )
149149 workSubmitCmd := make (map [string ]interface {})
150150 for k , v := range red .RemoteParams {
@@ -195,7 +195,7 @@ func (rw *remoteUnit) startRemoteUnit(ctx context.Context, conn net.Conn, reader
195195 if err != nil {
196196 return fmt .Errorf ("error sending stdin file: %s" , err )
197197 }
198- err = conn .Close ()
198+ err = conn .( interface { CloseWrite () error }). CloseWrite ()
199199 if err != nil {
200200 return fmt .Errorf ("error closing stdin file: %s" , err )
201201 }
@@ -220,7 +220,7 @@ func (rw *remoteUnit) startRemoteUnit(ctx context.Context, conn net.Conn, reader
220220func (rw * remoteUnit ) cancelOrReleaseRemoteUnit (ctx context.Context , conn net.Conn , reader * bufio.Reader ,
221221 release bool , force bool ,
222222) error {
223- defer conn .( interface { CloseConnection () error }). CloseConnection ()
223+ defer conn .Close ()
224224 red := rw .Status ().ExtraData .(* remoteExtraData )
225225 var workCmd string
226226 if release {
@@ -277,7 +277,7 @@ func (rw *remoteUnit) monitorRemoteStatus(mw *utils.JobContext, forRelease bool)
277277 conn , reader := rw .getConnection (mw )
278278 defer func () {
279279 if conn != nil {
280- conn .( interface { CloseConnection () error }). CloseConnection ()
280+ conn .Close ()
281281 }
282282 }()
283283 if conn == nil {
@@ -294,15 +294,15 @@ func (rw *remoteUnit) monitorRemoteStatus(mw *utils.JobContext, forRelease bool)
294294 _ , err := conn .Write ([]byte (fmt .Sprintf ("work status %s\n " , remoteUnitID )))
295295 if err != nil {
296296 logger .Debug ("Write error sending to %s: %s\n " , remoteUnitID , err )
297- _ = conn .( interface { CloseConnection () error }). CloseConnection ()
297+ _ = conn .Close ()
298298 conn = nil
299299
300300 continue
301301 }
302302 status , err := utils .ReadStringContext (mw , reader , '\n' )
303303 if err != nil {
304304 logger .Debug ("Read error reading from %s: %s\n " , remoteNode , err )
305- _ = conn .( interface { CloseConnection () error }). CloseConnection ()
305+ _ = conn .Close ()
306306 conn = nil
307307
308308 continue
@@ -401,7 +401,7 @@ func (rw *remoteUnit) monitorRemoteStdout(mw *utils.JobContext) {
401401 conn , reader := rw .getConnection (mw )
402402 defer func () {
403403 if conn != nil {
404- _ = conn .( interface { CloseConnection () error }). CloseConnection ()
404+ _ = conn .Close ()
405405 }
406406 }()
407407 if conn == nil {
@@ -461,7 +461,7 @@ func (rw *remoteUnit) monitorRemoteStdout(mw *utils.JobContext) {
461461 if ok {
462462 cr .CancelRead ()
463463 }
464- _ = conn .( interface { CloseConnection () error }). CloseConnection ()
464+ _ = conn .Close ()
465465
466466 return
467467 }
0 commit comments