func (r *fake_conn) run_queue(conn *net.UnixConn) {
	defer conn.Close()

	for {
		select {
		case <-r.end:
			return

		default:
			buffer := make([]byte, 1<<16)

			conn.SetReadDeadline(time.Now().Add(1000 * time.Millisecond))
			s, _, err := conn.ReadFrom(buffer)
			switch t_err := err.(type) {
			case nil:
			case net.Error:
				if !t_err.Timeout() {
					panic(err)
				}
			default:
				panic(err)
			}

			if s > 0 {
				r.queue <- buffer[0:s]
			}

		}
	}

}
Beispiel #2
0
func readAndCompare(conn *net.UnixConn, want string) error {
	buf := make([]byte, 128)

	// File system events can take a long time to propagate
	conn.SetDeadline(time.Now().Add(3 * time.Second))

	if _, _, err := conn.ReadFrom(buf); err != nil {
		return err
	}
	if have := string(bytes.Trim(buf, "\x00")); have != want {
		return fmt.Errorf("expected %q, got %q", want, have)
	}

	return nil
}
Beispiel #3
0
func (devlog *DevLogReader) cope_with(conn *net.UnixConn, buffer []byte, dest chan<- Message) {
	_, _, err := conn.ReadFrom(buffer)
	if err != nil {
		devlog.errchan <- &InputError{devlog.Driver, devlog.Id, "ReadFrom " + devlog.Devlog, err}
		return
	}

	line := rtrim_blank(buffer)
	if len(line) == 0 {
		return
	}

	l, err := parse_3164_or_5424(devlog.Id, line)
	if err != nil {
		devlog.errchan <- &InputError{devlog.Driver, devlog.Id, "parse_3164_or_5424 " + devlog.Devlog, err}
		return
	}

	dest <- l
}
Beispiel #4
0
func (jrnl *JournalReader) cope_with(conn *net.UnixConn, buffer []byte, dest chan<- Message) {
	_, _, err := conn.ReadFrom(buffer)
	if err != nil {
		jrnl.errchan <- &InputError{jrnl.Driver, jrnl.Id, "ReadFrom " + jrnl.Journald, err}
		return
	}

	line := rtrim_blank(buffer)
	if len(line) == 0 {
		return
	}

	l, err := parse_3164_or_5424(jrnl.Id, line)
	if err != nil {
		jrnl.errchan <- &InputError{jrnl.Driver, jrnl.Id, "parse_3164_or_5424 " + jrnl.Journald, err}
		return
	}

	dest <- l
}