Skip to content

Read blocks indefinitely on linux even with timeout #9

@soypat

Description

@soypat

Tested with raspberry Pi and my desktop:

Steps to reproduce

Modify ReadClose verification program to be as follows

Details
package main

import (
	"flag"
	"fmt"
	"io"
	"log"
	"time"

	"github.com/distributed/sers"
)

func main() {
	err := Main()
	if err != nil {
		log.Fatal(err)
	}
}

func readpart(r io.ReadCloser) error {
	go func() {
		time.Sleep(50 * time.Second)
		fmt.Printf("============================> close now\n")
		err := r.Close()
		fmt.Printf("close err %v\n", err)
	}()

	_, err := r.Read(make([]byte, 128))
	if err != nil {
		return err
	}

	return nil
}

func Main() error {
	flag.Parse()
	if len(flag.Args()) < 1 {
		return fmt.Errorf("please provide a serial file name")
	}
	fn := flag.Args()[0]

	f, err := sers.Open(fn)
	if err != nil {
		return err
	}
	err = f.SetReadParams(0, 1)
	if err != nil {
		return err
	}
	return readpart(f)
}

Program now blocks for 50 seconds even though timeout is 1 second.

I am available to help resolving this issue but am unfamiliar with this repo and CGo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions