(pipe *syncSocket, sync syncT)
| 88 | } |
| 89 | |
| 90 | func doWriteSync(pipe *syncSocket, sync syncT) error { |
| 91 | sync.Flags &= ^syncFlagHasFd |
| 92 | if sync.File != nil { |
| 93 | sync.Flags |= syncFlagHasFd |
| 94 | } |
| 95 | logrus.Debugf("writing sync %s", sync) |
| 96 | data, err := json.Marshal(sync) |
| 97 | if err != nil { |
| 98 | return fmt.Errorf("marshal sync %v: %w", sync.Type, err) |
| 99 | } |
| 100 | if _, err := pipe.WritePacket(data); err != nil { |
| 101 | return fmt.Errorf("writing sync %v: %w", sync.Type, err) |
| 102 | } |
| 103 | if sync.Flags&syncFlagHasFd != 0 { |
| 104 | logrus.Debugf("writing sync file %s", sync) |
| 105 | if err := cmsg.SendFile(pipe.File(), sync.File); err != nil { |
| 106 | return fmt.Errorf("sending file after sync %q: %w", sync.Type, err) |
| 107 | } |
| 108 | } |
| 109 | return nil |
| 110 | } |
| 111 | |
| 112 | func writeSync(pipe *syncSocket, sync syncType) error { |
| 113 | return doWriteSync(pipe, syncT{Type: sync}) |
no test coverage detected
searching dependent graphs…